private bool Is_Shutdown_Reason( EMatchRemovalReason reason ) { switch ( reason ) { case EMatchRemovalReason.Match_Shutdown: return true; case EMatchRemovalReason.Player_Request: case EMatchRemovalReason.Player_Disconnect_Timeout: default: return false; } }
// Construction public CMatchPlayerLeftMessage( EPersistenceID player_id, EMatchRemovalReason reason ) : base() { PlayerID = player_id; Reason = reason; }
public void Remove_From_Match( EMatchInstanceID match_id, EPersistenceID player_id, EMatchRemovalReason reason ) { CServerMatchInstance match_instance = Get_Match_Instance( match_id ); if ( match_instance == null ) { return; } if ( CConnectedPlayerManager.Instance.Is_Connected( player_id ) ) { CAsyncBackendOperations.Join_General_Channel( player_id, EMessageRequestID.Invalid ); } CConnectedPlayer player = CConnectedPlayerManager.Instance.Get_Player_By_Persistence_ID( player_id ); player.On_Leave_Match(); CMatchPlayerLeftMessage leave_message = new CMatchPlayerLeftMessage( player_id, reason ); bool is_match_shutdown = Is_Shutdown_Reason( reason ); if ( is_match_shutdown ) { CServerMessageRouter.Send_Message_To_Player( leave_message, player_id ); } else { match_instance.Send_Message_To_Members( leave_message, EPersistenceID.Invalid ); } match_instance.Remove_Member( player_id ); if ( match_instance.MemberCount == 0 ) { Shutdown_Match( match_id, EMatchDestroyedReason.Match_Empty ); } }