xTachyon

Untitled

Feb 14th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. void sessionHandleWrite(SessionSharedPtr ptr, const boost::system::error_code& error)
  2. {
  3.   if (error)
  4.   {
  5.     ptr->disconnect();
  6.   }
  7.   else
  8.   {
  9.     ptr->mIsWritting = false;
  10.     assert(!ptr->mIsWritting);
  11.    
  12.     ptr->writeNext();
  13.   }
  14. }
  15.  
  16. void Session::writeNext()
  17. {
  18.   if (mIsWritting || !mPacketsToBeSend.pop(mSendingPacket))
  19.   {
  20.     return;
  21.   }
  22.  
  23.   assert(!mIsWritting);
  24.   mIsWritting = true;
  25.  
  26.   assert(mIsWritting);
  27.   asio::async_write(mSocket, asio::buffer(mSendingPacket.data(), mSendingPacket.size()),
  28.                     boost::bind(sessionHandleWrite, shared_from_this(), asio::placeholders::error));
  29. }
Advertisement
Add Comment
Please, Sign In to add comment