private void Handle_Client_Hello_Request( CClientHelloRequest message, ESessionID session_id ) { CGetPlayerDataPersistenceRequest get_data_request = new CGetPlayerDataPersistenceRequest( message.Name ); get_data_request.Handler = delegate( CPersistenceResponse response ) { CGetPlayerDataPersistenceResponse get_data_response = response as CGetPlayerDataPersistenceResponse; EPersistenceID player_id = get_data_response.PlayerData.ID; CConnectedPlayerManager.Instance.Add_Connected_Player( session_id, player_id, message ); }; CDatabaseProxy.Instance.Submit_Request( get_data_request ); }
public void Add_Connected_Player( ESessionID session_id, EPersistenceID persistence_id, CClientHelloRequest request ) { if ( Get_Player_By_Session_ID( session_id ) != null ) { Send_Message( new CClientHelloResponse( request.RequestID, EConnectRefusalReason.Name_Already_Connected ), session_id ); Add_Network_Operation( new CDisconnectRequestOperation( session_id, EDisconnectReason.Server_Request ) ); return; } if ( Get_Active_Player_By_Persistence_ID( persistence_id ) != null ) { Send_Message( new CClientHelloResponse( request.RequestID, EConnectRefusalReason.Name_Already_Connected ), session_id ); Add_Network_Operation( new CDisconnectRequestOperation( session_id, EDisconnectReason.Server_Request ) ); return; } CPersistentPlayerData player_data = CDatabaseProxy.Instance.Get_Player_Data( persistence_id ); if ( player_data == null ) { Send_Message( new CClientHelloResponse( request.RequestID, EConnectRefusalReason.Internal_Persistence_Error ), session_id ); Add_Network_Operation( new CDisconnectRequestOperation( session_id, EDisconnectReason.Server_Request ) ); return; } CConnectedPlayer player = null; if ( m_SuspendedPlayers.TryGetValue( persistence_id, out player ) ) { m_SuspendedPlayers.Remove( persistence_id ); m_ConnectedPlayers.Add( persistence_id, player ); player.Resume( session_id ); CServerResource.Output_Text( EServerTextID.Server_Player_Reconnected_Notice, player.Name ); CLog.Log( ELoggingChannel.Logic, ELogLevel.Low, CServerResource.Get_Text( EServerTextID.Server_Player_Reconnected_Notice, player.Name ) ); } else { player = new CConnectedPlayer( persistence_id, session_id, request.Name ); m_ConnectedPlayers.Add( persistence_id, player ); CServerResource.Output_Text( EServerTextID.Server_Player_Connected_Notice, player.Name ); CLog.Log( ELoggingChannel.Logic, ELogLevel.Low, CServerResource.Get_Text( EServerTextID.Server_Player_Connected_Notice, player.Name ) ); } m_ActiveSessions.Add( session_id, persistence_id ); // add to chat CAsyncBackendOperations.New_Player_Announce_To_Chat( player, player_data, request.RequestID ); }