public CServerMatchInstance Get_Match_Instance( EMatchInstanceID id )
        {
            CServerMatchInstance match_instance = null;
            m_MatchInstances.TryGetValue( id, out match_instance );

            return match_instance;
        }
コード例 #2
0
        public CMatchInstance( EMatchInstanceID id, CLobbyState lobby_state )
        {
            GameState = new CGameState( lobby_state.GameMode );
            GameState.Initialize_Game( lobby_state.Players );

            MatchState = new CMatchState( id, lobby_state.GameMode, lobby_state.GameCount );
            MatchState.Initialize_Match( lobby_state.Players );
            MatchState.Add_Observers( lobby_state );
        }
コード例 #3
0
        public static void Create_Observer_Chat_Channel( CChatChannelConfig observer_channel_config, EMatchInstanceID match_id )
        {
            CCreateChatChannelRequestServerMessage create_observer_channel_message = new CCreateChatChannelRequestServerMessage( observer_channel_config );
            create_observer_channel_message.Handler =
                delegate( CResponseMessage response )
                {
                    CCreateChatChannelResponseServerMessage response_msg = response as CCreateChatChannelResponseServerMessage;
                    On_Observer_Chat_Channel_Creation_Response( match_id, response_msg );
                };

            CServerMessageRouter.Send_Message_To_Chat_Server( create_observer_channel_message );
        }
コード例 #4
0
        // Construction
        public CMatchInstance( EMatchInstanceID id, EPersistenceID player1, EPersistenceID player2, uint game_count )
        {
            GameState = new CGameState( EGameModeType.Two_Players );

            List< EPersistenceID > players = new List< EPersistenceID >();
            players.Add( player1 );
            players.Add( player2 );

            GameState.Initialize_Game( players );

            MatchState = new CMatchState( id, EGameModeType.Two_Players, game_count );
            MatchState.Initialize_Match( players );
        }
        public void On_Match_Chat_Channel_Creation_Response( EMatchInstanceID match_id, CCreateChatChannelResponseServerMessage response_msg )
        {
            CServerMatchInstance match_instance = Get_Match_Instance( match_id );
            if ( match_instance == null )
            {
                if ( response_msg.ChannelID != EChannelID.Invalid )
                {
                    CDestroyChatChannelServerMessage destroy_channel_message = new CDestroyChatChannelServerMessage( response_msg.ChannelID );
                    CServerMessageRouter.Send_Message_To_Chat_Server( destroy_channel_message );
                }

                return;
            }

            // Chat creation and joining should never fail
            if ( response_msg.Error != EChannelCreationError.None )
            {
                Shutdown_Match( match_id, EMatchDestroyedReason.Chat_Channel_Creation_Failure );
                return;
            }

            match_instance.MatchChannel = response_msg.ChannelID;
            match_instance.Perform_Match_Channel_Joins();
        }
コード例 #6
0
 public static void Join_Match_Channel( EMatchInstanceID match_id, EPersistenceID player_id, EChannelID match_channel_id )
 {
     Change_System_Channel( player_id,
                                   match_channel_id,
                                   EChannelGameProperties.OrdinarySingletonMask,
                                   delegate( CResponseMessage response ) {
                                         On_Match_Chat_Channel_Join_Response( match_id, player_id, response as CJoinChatChannelResponseServerMessage );
                                   } );
 }
コード例 #7
0
		// Construction
		public CMatchState( EMatchInstanceID match_id, EGameModeType mode, uint game_count )
		{
			ID = match_id;
			Mode = mode;
			GameCount = game_count;
			CurrentGameNumber = 1;
		}
コード例 #8
0
 private static void On_Observer_Chat_Channel_Join_Response( EMatchInstanceID match_id, EPersistenceID player_id, CJoinChatChannelResponseServerMessage response )
 {
     CServerMatchInstanceManager.Instance.On_Observer_Chat_Channel_Join_Response( match_id, player_id, response );
 }
コード例 #9
0
 private static void On_Observer_Chat_Channel_Creation_Response( EMatchInstanceID match_id, CCreateChatChannelResponseServerMessage response_msg )
 {
     CServerMatchInstanceManager.Instance.On_Observer_Chat_Channel_Creation_Response( match_id, response_msg );
 }
コード例 #10
0
 public CServerMatchInstance( EMatchInstanceID match_id, EPersistenceID player1, EPersistenceID player2, uint game_count )
     : base(match_id, player1, player2, game_count)
 {
     MatchChannel = EChannelID.Invalid;
     ObserverChannel = EChannelID.Invalid;
 }
コード例 #11
0
 // Construction
 public CServerMatchInstance( EMatchInstanceID match_id, CLobbyState lobby_state )
     : base(match_id, lobby_state)
 {
     MatchChannel = EChannelID.Invalid;
     ObserverChannel = EChannelID.Invalid;
 }
コード例 #12
0
 // Construction
 public CMatchShutdownTask( EMatchInstanceID match_id, long schedule_time )
     : base(schedule_time)
 {
     MatchID = match_id;
 }
コード例 #13
0
 public void On_Start_Match( EMatchInstanceID match_id )
 {
     State = EConnectedPlayerState.Game_Idle;
     MatchID = match_id;
     LobbyID = ELobbyID.Invalid;
 }
コード例 #14
0
        private void Transition_To_Match( EMatchInstanceID match_id )
        {
            Create_Match_Channels( match_id );

            Get_Match_Instance( match_id ).PlayersAndObservers.Apply( pid => CConnectedPlayerManager.Instance.Get_Player_By_Persistence_ID( pid ).On_Start_Match( match_id ) );

            Start_Match( match_id );
        }
コード例 #15
0
        public void On_Observer_Chat_Channel_Join_Response( EMatchInstanceID match_id, EPersistenceID player_id, CJoinChatChannelResponseServerMessage response )
        {
            CServerMatchInstance match_instance = Get_Match_Instance( match_id );
            if ( match_instance == null )
            {
                return;
            }

            // Chat creation and joining should never fail
            if ( response.Error != EChannelJoinError.None )
            {
                Shutdown_Match( match_id, EMatchDestroyedReason.Chat_Channel_Join_Failure );
                return;
            }
        }
コード例 #16
0
        private void Start_Match( EMatchInstanceID match_id )
        {
            CServerMatchInstance match_instance = Get_Match_Instance( match_id );
            if ( match_instance == null )
            {
                throw new CApplicationException( "Starting match but it doesn't exist" );
            }

            match_instance.Start();
        }
コード例 #17
0
        private void Create_Match_Channels( EMatchInstanceID match_id )
        {
            CChatChannelConfig match_channel_config = new CChatChannelConfig( CChatChannelConfig.Make_Admin_Channel( "Match_" + ( ( int ) match_id ).ToString() ),
                                                                                                    CSharedResource.Get_Text< EServerTextID >( EServerTextID.Server_Match_Channel_Name ),
                                                                                                    EPersistenceID.Invalid,
                                                                                                    EChannelGameProperties.MatchPlayer );
            match_channel_config.AllowsModeration = false;
            match_channel_config.AnnounceJoinLeave = false;
            match_channel_config.DestroyWhenEmpty = false;
            match_channel_config.IsMembershipClientLocked = true;

            CAsyncBackendOperations.Create_Match_Chat_Channel( match_channel_config, match_id );

            CChatChannelConfig observer_channel_config = new CChatChannelConfig( CChatChannelConfig.Make_Admin_Channel( "Observer_" + ( ( int ) match_id ).ToString() ),
                                                                                                        CSharedResource.Get_Text< EServerTextID >( EServerTextID.Server_Observer_Channel_Name ),
                                                                                                        EPersistenceID.Invalid,
                                                                                                        EChannelGameProperties.MatchObserver );
            observer_channel_config.AllowsModeration = false;
            observer_channel_config.AnnounceJoinLeave = false;
            observer_channel_config.DestroyWhenEmpty = false;
            observer_channel_config.IsMembershipClientLocked = true;

            CAsyncBackendOperations.Create_Observer_Chat_Channel( observer_channel_config, match_id );
        }
コード例 #18
0
        public void Shutdown_Match( EMatchInstanceID match_id, EMatchDestroyedReason reason )
        {
            CServerMatchInstance match_instance = Get_Match_Instance( match_id );
            if ( match_instance == null )
            {
                return;
            }

            match_instance.PlayersAndObservers.Duplicate_As_List().Apply( mid => Remove_From_Match( match_id, mid, Compute_Removal_Reason( reason ) ) );

            if ( match_instance.MatchChannel != EChannelID.Invalid )
            {
                CDestroyChatChannelServerMessage destroy_channel_message = new CDestroyChatChannelServerMessage( match_instance.MatchChannel );
                CServerMessageRouter.Send_Message_To_Chat_Server( destroy_channel_message );
            }

            if ( match_instance.ObserverChannel != EChannelID.Invalid )
            {
                CDestroyChatChannelServerMessage destroy_channel_message = new CDestroyChatChannelServerMessage( match_instance.ObserverChannel );
                CServerMessageRouter.Send_Message_To_Chat_Server( destroy_channel_message );
            }

            match_instance.Shutdown();

            m_MatchInstances.Remove( match_id );
        }
コード例 #19
0
        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 );
            }
        }
コード例 #20
0
        public void On_Player_Reconnect( EPersistenceID player_id, EMatchInstanceID match_id )
        {
            CServerMatchInstance match_instance = Get_Match_Instance( match_id );
            if ( match_instance == null )
            {
                return;
            }

            match_instance.On_Player_Reconnect( player_id );
        }