server/CNetworkManager.cpp
// LIBRG_CONNECTION_DISCONNECT
// client disconnects or timed out, no data sending
LIBRG_CONNECTION_DISCONNECT
client disconnects or timed out, no data sending
LIBRG_CONNECTION_DISCONNECT client disconnects or timed out no data sending
void CNetworkManager::on_disconnect(librg_event_t* event)
{
	CServerPlayer* player = (CServerPlayer*)event->entity->user_data;
	if (player) 
	{
        CNetworkEntityManager::players.erase(std::remove(CNetworkEntityManager::players.begin(), CNetworkEntityManager::players.end(), player), CNetworkEntityManager::players.end());
		delete player;
		event->entity->user_data = nullptr;
		player = nullptr;
		librg_entity_control_remove(event->ctx, event->entity->id);
		librg_message_send_except(&ctx, eNetworkEvents::UNREGISTER_REMOTE_CLIENT, event->entity->client_peer, &event->entity->id, sizeof(u32));
	}
	CLog::Log("[CNetworkManager] Network client %d disconnected from server.\n", event->entity->id);
}
void CNetworkManager :: on_disconnect ( librg_event_t * event ) { CServerPlayer * player = ( CServerPlayer * ) event -> entity -> user_data ; if ( player ) { CNetworkEntityManager :: players . erase ( std :: remove ( CNetworkEntityManager :: players . begin ( ) , CNetworkEntityManager :: players . end ( ) , player ) , CNetworkEntityManager :: players . end ( ) ) ; delete player ; event -> entity -> user_data = nullptr ; player = nullptr ; librg_entity_control_remove ( event -> ctx , event -> entity -> id ) ; librg_message_send_except ( & ctx , eNetworkEvents :: UNREGISTER_REMOTE_CLIENT , event -> entity -> client_peer , & event -> entity -> id , sizeof ( u32 ) ) ; } CLog :: Log ( " \n " , event -> entity -> id ) ; }
LIBRG_CONNECTION_DISCONNECT
client disconnects or timed out, no data sending
LIBRG_CONNECTION_DISCONNECT client disconnects or timed out no data sending
//if its null, the player is disconnected before connection finished