void onMessage(const TcpConnectionPtr& pTcpConn, Buffer* buffer, TimeStamp reveiveTime) { printf("onMessage(): tid=%d received %zd bytes from connection [%s] at %s \n", CurrentThread::GetTid() , buffer->ReadableBytes() , pTcpConn->GetName().c_str() , reveiveTime.ToFormattedString().c_str()); printf("onMessage(): [%s]\n", buffer->RetrieveAsString().c_str()); }
void onConnection(const TcpConnectionPtr& pTcpConn) { if (pTcpConn->IsConnected()) { printf("onConnection(): tid=%d new connection [%s] from %s\n" , CurrentThread::GetTid() , pTcpConn->GetName().c_str() , pTcpConn->GetPeerAddress().ToHostPort().c_str()); } else { printf("onConnection(): tid=%d connection [%s] is down\n", CurrentThread::GetTid(), pTcpConn->GetName().c_str()); } }