void TcpServer::_listen_cb( int fd, short events, void * arg ) { if(events & EV_READ) { TcpServer * server = (TcpServer *)arg; server->Accept(); } else if(events & EV_WRITE) { TcpServer * server = (TcpServer *)arg; event_base_loopbreak(server->_base); } }
void TcpServer::OnNewConnection( uv_stream_t* server_stream, int status ) { assert( status == 0 ); TcpServer* server = static_cast<TcpServer*>( server_stream->data ); if ( status == -1 ) { } else { int client_id = server->Accept(); if ( client_id && server->m_new_client_callback ) { server->m_new_client_callback( client_id ); } } }