private void Handle_Start_Browse_Lobby_Response( CStartBrowseLobbyResponse response ) { Clear_Lobbies(); switch ( response.Result ) { case EStartBrowseResult.AutoJoined: State = EClientBrowseState.None; break; case EStartBrowseResult.Success: State = EClientBrowseState.Browse_Idle; response.LobbySummaries.Apply( summary => Add_Summary( summary ) ); CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Browse_Start_Success ); break; case EStartBrowseResult.Invalid_State: State = EClientBrowseState.None; CClientResource.Output_Text< EClientTextID >( EClientTextID.Client_Browse_Start_Invalid_State ); break; default: State = EClientBrowseState.None; break; } }
private static void Build_Browse_Lobby_Message_Samples( List< CNetworkMessage > message_list ) { message_list.Add( new CStartBrowseLobbyRequest( EGameModeType.Two_Players, ELobbyMemberType.Player, true ) ); CLobbyConfig lobby_config = new CLobbyConfig(); lobby_config.Initialize( "Pimps", EGameModeType.Two_Players, false, "BigPimpin" ); CStartBrowseLobbyResponse browse_response = new CStartBrowseLobbyResponse( EMessageRequestID.Invalid, EStartBrowseResult.Success ); for ( int i = 0; i < 10; i++ ) { CLobbySummary lobby_summary = new CLobbySummary(); lobby_summary.Initialize( ELobbyID.Invalid, lobby_config, DateTime.Now, EPersistenceID.Invalid, 2, 2 ); browse_response.Add_Summary( lobby_summary ); } message_list.Add( browse_response ); message_list.Add( new CEndBrowseLobbyMessage() ); message_list.Add( new CBrowseNextLobbySetRequest() ); message_list.Add( new CBrowsePreviousLobbySetRequest() ); CCursorBrowseLobbyResponse cursor_response = new CCursorBrowseLobbyResponse( EMessageRequestID.Invalid, ECursorBrowseResult.Success ); for ( int i = 0; i < 10; i++ ) { CLobbySummary lobby_summary = new CLobbySummary(); lobby_summary.Initialize( ELobbyID.Invalid, lobby_config, DateTime.Now, EPersistenceID.Invalid, 2, 2 ); cursor_response.Add_Summary( lobby_summary ); } message_list.Add( cursor_response ); CLobbySummary summary = new CLobbySummary(); summary.Initialize( ELobbyID.Invalid, lobby_config, DateTime.Now, EPersistenceID.Invalid, 1, 4 ); message_list.Add( new CBrowseLobbyAddRemoveMessage( summary, ELobbyID.Invalid ) ); CLobbySummaryDelta summary_delta = new CLobbySummaryDelta(); summary_delta.Initialize( ELobbyID.Invalid, 4, 1 ); message_list.Add( new CBrowseLobbyDeltaMessage( summary_delta ) ); }
private void Handle_Start_Browse_Lobby_Request( CStartBrowseLobbyRequest request, EPersistenceID player_id ) { CConnectedPlayer player = CConnectedPlayerManager.Instance.Get_Active_Player_By_Persistence_ID( player_id ); if ( player == null ) { return; } if ( !player.State_Allows_Operation( EConnectedPlayerOperation.Browse_Lobbies ) ) { CServerMessageRouter.Send_Message_To_Player( new CStartBrowseLobbyResponse( request.RequestID, EStartBrowseResult.Invalid_State ), player_id ); return; } CLog.Log( ELoggingChannel.Lobby, ELogLevel.Medium, String.Format( "Player {0} requesting to start browsing lobbies.", CConnectedPlayerManager.Get_Player_Log_Name( player_id ) ) ); Stop_Browsing( player_id ); CServerLobbyBrowser browser = new CServerLobbyBrowser( player_id, request.BrowseCriteria, request.JoinFirstAvailable ); m_Browsers.Add( player_id, browser ); Browse_Forwards( browser, 0 ); if ( browser.Has_Matches() && request.JoinFirstAvailable ) { ELobbyID lobby_id = browser.WatchedLobbies.First(); Stop_Browsing( player_id ); CServerMessageRouter.Send_Message_To_Player( new CStartBrowseLobbyResponse( request.RequestID, EStartBrowseResult.AutoJoined ), player_id ); CServerLobbyManager.Instance.Join_Lobby_By_Browsing( player_id, lobby_id ); return; } // send initial lobby set CStartBrowseLobbyResponse response = new CStartBrowseLobbyResponse( request.RequestID, EStartBrowseResult.Success ); browser.WatchedLobbies.Apply( lobby_id => response.Add_Summary( Build_Summary( lobby_id ) ) ); CServerMessageRouter.Send_Message_To_Player( response, player_id ); }