GaiaTCP/Connection.cpp
/// Add listen task to the io service, the task can add itself when it finishes.
Add listen task to the io service, the task can add itself when it finishes.
Add listen task to the io service the task can add itself when it finishes .
void Connection::AddListenTask()
    {
        auto buffer = std::make_shared<std::string>();
        buffer->resize(this->ReceiverBufferSize);
        IOSocket.async_read_some(boost::asio::buffer(buffer->data(), buffer->size()),
        [this, passed_buffer = buffer](
                const boost::system::error_code& error, std::size_t length)
        {
            if (error) return;
            passed_buffer->resize(length);
            this->OnReceive.Trigger(*passed_buffer);
            this->AddListenTask();
        });
    }
void Connection :: AddListenTask ( ) { auto buffer = std :: make_shared < std :: string > ( ) ; buffer -> resize ( this -> ReceiverBufferSize ) ; IOSocket . async_read_some ( boost :: asio :: buffer ( buffer -> data ( ) , buffer -> size ( ) ) , [ this , passed_buffer = buffer ] ( const boost :: system :: error_code & error , std :: size_t length ) { if ( error ) return ; passed_buffer -> resize ( length ) ; this -> OnReceive . Trigger ( * passed_buffer ) ; this -> AddListenTask ( ) ; } ) ; }
Add listen task to the io service, the task can add itself when it finishes.
Add listen task to the io service the task can add itself when it finishes .