// Public interface // Operations // Channel Creation public static void Create_Lobby_Chat_Channel( CChatChannelConfig channel_config, ELobbyID lobby_id, EPersistenceID source_player ) { CCreateChatChannelRequestServerMessage create_lobby_channel_message = new CCreateChatChannelRequestServerMessage( channel_config ); create_lobby_channel_message.Handler = delegate( CResponseMessage response ) { CCreateChatChannelResponseServerMessage response_msg = response as CCreateChatChannelResponseServerMessage; On_Lobby_Chat_Channel_Creation_Response( lobby_id, source_player, response_msg ); }; CServerMessageRouter.Send_Message_To_Chat_Server( create_lobby_channel_message ); }
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 ); }
private void Request_Create_Or_Join_Channel( EPersistenceID player_id, string channel_name, CJoinChatChannelResultMessage result_msg ) { if ( Get_Player_By_Persistence_ID( player_id ) == null ) { result_msg.CreateError = EChannelCreationError.UnknownPlayer; return; } if ( !CServerChatChannel.Is_Client_Channel_Name( channel_name ) ) { result_msg.CreateError = EChannelCreationError.InvalidInternalName; return; } CServerChatChannel channel = Get_Channel_By_Internal_Name( channel_name ); if ( channel == null ) { CChatChannelConfig channel_config = new CChatChannelConfig( channel_name, channel_name, player_id, EChannelGameProperties.User ); channel_config.DestroyWhenEmpty = true; channel_config.AllowsModeration = true; result_msg.CreateError = channel_config.Make_Valid(); if ( result_msg.CreateError != EChannelCreationError.None ) { return; } EChannelID channel_id = Allocate_Channel_ID(); channel = new CServerChatChannel( channel_id, channel_config ); m_Channels.Add( channel_id, channel ); m_ChannelInternalNames.Add( channel_config.InternalName.ToUpper(), channel_id ); } if ( channel.IsServerChannel ) { result_msg.JoinError = EChannelJoinError.NoPermission; return; } result_msg.JoinError = channel.Join_Channel( player_id ); if ( result_msg.JoinError == EChannelJoinError.None ) { channel.Update_Moderator(); Add_Channel_To_Player( player_id, channel.ID ); result_msg.ChannelID = channel.ID; result_msg.ChannelName = channel.ExternalName; result_msg.AnnounceJoinLeave = channel.ShouldAnnounceJoinLeave; channel.Members.Apply( id => result_msg.Add_Member( id ) ); channel.Gagged.Apply( id => result_msg.Add_Gagged( id ) ); Send_Notification_To_Channel( channel.ID, player_id, EChatNotification.Player_Joined_Channel, player_id ); if ( channel.Update_Moderator() ) { Send_Notification_To_Channel( channel.ID, channel.Moderator, EChatNotification.New_Moderator, EPersistenceID.Invalid ); } result_msg.Moderator = channel.Moderator; } else { Request_Destroy_Channel( channel.ID ); } }
private void Request_Create_Channel( CChatChannelConfig channel_config, CCreateChatChannelResponseServerMessage response_msg ) { response_msg.Error = channel_config.Make_Valid(); if ( response_msg.Error != EChannelCreationError.None ) { return; } if ( channel_config.CreatorID != EPersistenceID.Invalid ) { if ( Get_Player_By_Persistence_ID( channel_config.CreatorID ) == null ) { response_msg.Error = EChannelCreationError.UnknownPlayer; return; } } if ( Get_Channel_By_Internal_Name( channel_config.InternalName ) != null ) { response_msg.Error = EChannelCreationError.DuplicateInternalName; return; } EChannelID channel_id = Allocate_Channel_ID(); CServerChatChannel new_channel = new CServerChatChannel( channel_id, channel_config ); m_Channels.Add( channel_id, new_channel ); m_ChannelInternalNames.Add( channel_config.InternalName.ToUpper(), channel_id ); response_msg.ChannelID = channel_id; response_msg.ChannelName = channel_config.ExternalName; if ( channel_config.CreatorID != EPersistenceID.Invalid ) { if ( Request_Join_Channel( channel_config.CreatorID, channel_id, EChannelGameProperties.None ) != EChannelJoinError.None ) { response_msg.Error = EChannelCreationError.UnableToAutoJoin; Request_Destroy_Channel( channel_id ); return; } } }
// Construction public CCreateChatChannelRequestServerMessage( CChatChannelConfig config ) : base() { Config = config; }
private void Request_Create_Lobby( CCreateLobbyRequest create_request, EPersistenceID source_player ) { CConnectedPlayer player = CConnectedPlayerManager.Instance.Get_Active_Player_By_Persistence_ID( source_player ); if ( player == null ) { return; } if ( !player.State_Allows_Operation( EConnectedPlayerOperation.Create_Lobby ) ) { On_Create_Lobby_Failure( ELobbyID.Invalid, source_player, create_request.RequestID, ECreateLobbyFailureReason.Invalid_State_To_Create ); return; } if ( !Validate_Create_Request( create_request.Config ) ) { On_Create_Lobby_Failure( ELobbyID.Invalid, source_player, create_request.RequestID, ECreateLobbyFailureReason.Invalid_Config_Data ); return; } CLog.Log( ELoggingChannel.Lobby, ELogLevel.Medium, String.Format( "Player {0} attempting to create lobby with description {1}.", player.Name, create_request.Config.GameDescription ) ); CServerLobbyBrowserManager.Instance.Stop_Browsing( source_player ); EMessageRequestID request_id = create_request.RequestID; CServerLobby lobby = Create_Lobby( source_player, create_request.Config ); lobby.Add_Member( source_player ); On_Create_Lobby_Success( source_player, request_id, lobby.ID ); CChatChannelConfig channel_config = new CChatChannelConfig( CChatChannelConfig.Make_Admin_Channel( "Lobby_" + ( ( int ) lobby.ID ).ToString() ), CSharedResource.Get_Text< EServerTextID >( EServerTextID.Server_Lobby_Channel_Name ), EPersistenceID.Invalid, EChannelGameProperties.Lobby ); channel_config.AllowsModeration = false; channel_config.AnnounceJoinLeave = false; channel_config.DestroyWhenEmpty = false; channel_config.IsMembershipClientLocked = true; CAsyncBackendOperations.Create_Lobby_Chat_Channel( channel_config, lobby.ID, source_player ); }
// Methods // Public interface public void Initialize_Chat() { CChatChannelConfig config = new CChatChannelConfig( CChatChannelConfig.Make_Admin_Channel( GENERAL_CHANNEL_NAME ), GENERAL_CHANNEL_NAME, EPersistenceID.Invalid, EChannelGameProperties.General ); config.AnnounceJoinLeave = false; config.IsMembershipClientLocked = true; CCreateChatChannelRequestServerMessage create_request = new CCreateChatChannelRequestServerMessage( config ); create_request.Handler = On_General_Chat_Creation_Response; CServerMessageRouter.Send_Message_To_Chat_Server( create_request ); }
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 ); }
// Construction public CServerChatChannel( EChannelID id, CChatChannelConfig config ) { ID = id; m_Config = config; IsBeingDestroyed = false; }