void NetServer::onLeaveUdpGroup( const NetGroupOp& op ) { NetGroupMap::iterator i = m_groups.find( op.groupId ); if ( i == m_groups.end() ) { LOG( FT_WARN, _T("NetServer::onLeaveUdpGroup> %d not found"), op.groupId ); return; } TcpConnection* c = m_tcp.FindById( op.connectionId ); if ( c != 0 ) { c->SetGroup( 0 ); } NetGroup* group = i->second; K_ASSERT( group != 0 ); group->Leave( op.connectionId ); LOG( FT_DEBUG, _T("NetServer::onLeaveUdpGroup> %d left from %d"), op.connectionId, group->GetId() ); }
void NetServer::onDestroyUdpGroup( const NetGroupOp& op ) { NetGroupMap::iterator i = m_groups.find( op.groupId ); if ( i == m_groups.end() ) { LOG( FT_WARN, _T("NetServer::onDestroyUdpGroup> %d not found"), op.groupId ); return; } NetGroup* group = i->second; K_ASSERT( group != 0 ); // make TcpConnection to forget about group const std::vector<uint>& remotes = group->GetRemotes(); std::vector<uint>::const_iterator ci( remotes.begin() ); std::vector<uint>::const_iterator ciEnd( remotes.end() ); for ( ; ci != ciEnd; ++ci ) { TcpConnection* c = m_tcp.FindById( *ci ); if ( c != 0 ) { c->SetGroup( 0 ); } } group->Fini(); LOG( FT_DEBUG, _T("NetServer::onDestroyUdpGroup> %d destroyed"), group->GetId() ); delete group; m_groups.erase( i ); }
void NetServer::onJoinUdpGroup( const NetGroupOp& op ) { NetGroupMap::iterator i = m_groups.find( op.groupId ); if ( i == m_groups.end() ) { LOG( FT_WARN, _T("NetServer::onJoinUdpGroup> %d not found"), op.groupId ); // TODO: error report return; } TcpConnection* c = m_tcp.FindById( op.connectionId ); if ( c == 0 ) { LOG( FT_WARN, _T("NetServer::onJoinUdpGroup> Connection %d not found"), op.connectionId ); return; } NetGroup* group = i->second; K_ASSERT( group != 0 ); c->SetGroup( op.groupId ); (void)group->Join( op.connectionId, c->GetSocket()->GetPeerAddress(), op.extra ); LOG( FT_DEBUG, _T("NetServer::onJoinUdpGroup> %d joined to %d"), op.connectionId, group->GetId() ); }