public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, int maxPlayersDefault, TimeSpan joinTimeOut) { if (log.IsDebugEnabled) { log.DebugFormat("Creating lobby: name={0}, type={1}", lobbyName, lobbyType); } this.Application = application; this.LobbyName = lobbyName; this.MaxPlayersDefault = maxPlayersDefault; this.JoinTimeOut = joinTimeOut; switch (lobbyType) { default: this.GameList = new GameList(this); break; case AppLobbyType.ChannelLobby: this.GameList = new GameChannelList(this); break; case AppLobbyType.SqlLobby: this.GameList = new SqlGameList(this); break; } this.ExecutionFiber = new PoolFiber(); this.ExecutionFiber.Start(); }
public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, int maxPlayersDefault, TimeSpan joinTimeOut) { if (log.IsDebugEnabled) { log.DebugFormat("Creating lobby: name={0}, type={1}", lobbyName, lobbyType); } this.Application = application; this.LobbyName = lobbyName; this.MaxPlayersDefault = maxPlayersDefault; this.JoinTimeOut = joinTimeOut; switch (lobbyType) { default: this.GameList = new GameList(this); break; case AppLobbyType.ChannelLobby: this.GameList = new GameChannelList(this); break; case AppLobbyType.SqlLobby: this.GameList = new SqlGameList(this); break; } this.ExecutionFiber = new PoolFiber(); this.ExecutionFiber.Start(); }
// only returns true public bool GetOrCreateAppLobby(string lobbyName, AppLobbyType lobbyType , out AppLobby lobby) { if (string.IsNullOrEmpty(lobbyName)) { lobby = this.defaultLobby; return true; } var key = new KeyValuePair<string, AppLobbyType>(lobbyName, lobbyType); lock (this.lobbyDict) { if (this.lobbyDict.TryGetValue(key, out lobby)) { return true; } lobby = this.CreateAppLobby(lobbyName, lobbyType); this.lobbyDict.Add(key, lobby); } if (log.IsDebugEnabled) { log.DebugFormat("Created lobby: name={0}, type={1}", lobbyName, lobbyType); } return true; }
private AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, int maxPlayersDefault, TimeSpan joinTimeOut, bool?useLegacyLobbies, int?limitGameList, int?limitGameListUpdate, int?limitSqlFilterResults, string matchmakingStoredProcedure = null) { if (log.IsDebugEnabled) { log.DebugFormat("Creating lobby: name={0}, type={1}", lobbyName, lobbyType); string limitGameListStr = limitGameList != null?limitGameList.ToString() : "null"; string useLegacylobbiesStr = useLegacyLobbies != null?useLegacyLobbies.ToString() : "null"; string limitGameListUpdateStr = limitGameListUpdate != null?limitGameListUpdate.ToString() : "null"; string limitSqlFilterResultsStr = limitSqlFilterResults != null?limitSqlFilterResults.ToString() : "null"; log.DebugFormat("AppLobby - useLegacyLobbies {0}, limitGameList {1}, limitGameListUpdate {2}, limitSqlFilterResults {3}", useLegacylobbiesStr, limitGameListStr, limitGameListUpdateStr, limitSqlFilterResultsStr); log.DebugFormat("MasterServerSettings - useLegacyLobbies {0}, limitGameList {1}, limitGameListUpdate {2}," + " limitSqlFilterResults {3}", MasterServerSettings.Default.UseLegacyLobbies, MasterServerSettings.Default.LimitGameList, MasterServerSettings.Default.LimitGameListUpdate, MasterServerSettings.Default.LimitSqlFilterResults); } this.Application = application; this.LobbyName = lobbyName; this.LobbyType = lobbyType; this.MaxPlayersDefault = maxPlayersDefault; this.JoinTimeOut = joinTimeOut; this.gameListLimit = limitGameList.HasValue ? limitGameList.Value : MasterServerSettings.Default.GameListLimit; application.IncrementLobbiesCount(); if (MasterServerSettings.Default.GameChangesPublishInterval > 0) { this.gameChangesPublishInterval = MasterServerSettings.Default.GameChangesPublishInterval; } switch (lobbyType) { default: this.GameList = new LimitedGameList(this, useLegacyLobbies, limitGameList, limitGameListUpdate); break; case AppLobbyType.ChannelLobby: this.GameList = new GameChannelList(this); break; case AppLobbyType.SqlLobby: this.GameList = new SqlFilterGameList(this, useLegacyLobbies, limitSqlFilterResults, matchmakingStoredProcedure); break; case AppLobbyType.AsyncRandomLobby: this.GameList = new AsyncRandomGameList(this); break; } InitUpdateLobbyLimits(application); InitUpdateMatchmakingStoredProcedure(application); this.ExecutionFiber = new PoolFiber(); this.ExecutionFiber.Start(); }
public bool GetOrCreateAppLobby(string lobbyName, AppLobbyType lobbyType, out AppLobby lobby) { if (string.IsNullOrEmpty(lobbyName)) { lobby = this.defaultLobby; return(true); } var key = new KeyValuePair <string, AppLobbyType>(lobbyName, lobbyType); lock (this.lobbyDict) { if (this.lobbyDict.TryGetValue(key, out lobby)) { return(true); } lobby = new AppLobby(this.application, lobbyName, lobbyType); this.lobbyDict.Add(key, lobby); } if (log.IsDebugEnabled) { log.DebugFormat("Created lobby: name={0}, type={1}", lobbyName, lobbyType); } return(true); }
/// <summary> /// Joins the lobby on the Master Server, where you get a list of RoomInfos of currently open rooms. /// This is an async request which triggers a OnOperationResponse() call. /// /// </summary> /// <param name="lobbyName">The lobby join to.</param> /// <param name="lobbyType">type of lobby</param> /// <returns> /// If the operation could be sent (has to be connected). /// </returns> public virtual bool OpJoinLobby(string lobbyName, AppLobbyType lobbyType) { var request = CreateOperationRequest(OperationCode.JoinLobby); request.Parameters[ParameterCode.LobbyName] = lobbyName; request.Parameters[ParameterCode.LobbyType] = (byte)lobbyType; this.SendRequestAndWaitForResponse(request); return(true); }
/// <summary> /// Joins the lobby on the Master Server, where you get a list of RoomInfos of currently open rooms. /// This is an async request which triggers a OnOperationResponse() call. /// /// </summary> /// <param name="lobbyName">The lobby join to.</param> /// <param name="lobbyType">type of lobby</param> /// <returns> /// If the operation could be sent (has to be connected). /// </returns> public virtual bool OpJoinLobby(string lobbyName, AppLobbyType lobbyType) { var request = CreateOperationRequest(OperationCode.JoinLobby); request.Parameters[ParameterCode.LobbyName] = lobbyName; request.Parameters[ParameterCode.LobbyType] = (byte)lobbyType; var response = this.SendRequestAndWaitForResponse(request); this.authenticationScheme.HandleAuthenticateResponse(this, response.Parameters); return(true); }
public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, int maxPlayersDefault, TimeSpan joinTimeOut) { if (log.IsDebugEnabled) { log.DebugFormat("Creating lobby: name={0}, type={1}", lobbyName, lobbyType); } this.Application = application; this.LobbyName = lobbyName; this.LobbyType = lobbyType; this.MaxPlayersDefault = maxPlayersDefault; this.JoinTimeOut = joinTimeOut; this.gameListLimit = MasterServerSettings.Default.GameListLimit; if (MasterServerSettings.Default.GameChangesPublishInterval > 0) { this.gameChangesPublishInterval = MasterServerSettings.Default.GameChangesPublishInterval; } switch (lobbyType) { default: this.GameList = new GameList(this); break; case AppLobbyType.ChannelLobby: this.GameList = new GameChannelList(this); break; case AppLobbyType.SqlLobby: this.GameList = new SqlGameList(this); break; case AppLobbyType.AsyncRandomLobby: this.GameList = new AsyncRandomGameList(this); break; } this.ExecutionFiber = new PoolFiber(); this.ExecutionFiber.Start(); }
// only returns true public bool GetOrCreateAppLobby(string lobbyName, AppLobbyType lobbyType, out AppLobby lobby, out string errorMsg) { if (string.IsNullOrEmpty(lobbyName)) { lobby = this.defaultLobby; errorMsg = string.Empty; return(true); } var key = new KeyValuePair <string, AppLobbyType>(lobbyName, lobbyType); lock (this.lobbyDict) { if (this.lobbyDict.TryGetValue(key, out lobby)) { errorMsg = string.Empty; return(true); } if (this.application.LobbiesCount >= MasterServerSettings.Default.LobbiesCountLimit) { lobby = null; errorMsg = LBErrorMessages.LobbiesLimitReached; return(false); } lobby = this.CreateAppLobby(lobbyName, lobbyType); this.lobbyDict.Add(key, lobby); } if (log.IsDebugEnabled) { log.DebugFormat("Created lobby: name={0}, type={1}", lobbyName, lobbyType); } errorMsg = string.Empty; return(true); }
public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType) : this(application, lobbyName, lobbyType, 0, TimeSpan.FromSeconds(15)) { }
public LobbyFactory(GameApplication application, AppLobbyType defaultLobbyType) { this.application = application; this.defaultLobby = new AppLobby(this.application, string.Empty, defaultLobbyType); }
public LobbyFactory(GameApplication application, AppLobbyType defaultLobbyType) { this.application = application; this.defaultLobbyType = defaultLobbyType; }
protected virtual AppLobby CreateAppLobby(string lobbyName, AppLobbyType lobbyType) { return(new AppLobby(this.application, lobbyName, lobbyType)); }
public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType, bool?useLegacyLobbies = null, int?limitGameList = null, int?limitGameListUpdate = null, int?limitSqlFilterResults = null, string matchmakingStoredProcedure = null) : this(application, lobbyName, lobbyType, 0, TimeSpan.FromSeconds(15), useLegacyLobbies, limitGameList, limitGameListUpdate, limitSqlFilterResults, matchmakingStoredProcedure) { }
public LobbyFactory(GameApplication application, AppLobbyType defaultLobbyType) { this.application = application; this.defaultLobbyType = defaultLobbyType; }
public LobbyFactory(GameApplication application, AppLobbyType defaultLobbyType) { this.application = application; this.defaultLobby = new AppLobby(this.application, string.Empty, defaultLobbyType); }
protected virtual AppLobby CreateAppLobby(string lobbyName, AppLobbyType lobbyType) { return new AppLobby(this.application, lobbyName, lobbyType); }
public AppLobby(GameApplication application, string lobbyName, AppLobbyType lobbyType) : this(application, lobbyName, lobbyType, 0, TimeSpan.FromSeconds(15)) { }
protected virtual void HandleCreateGameOperationBody(LitePeer peer, JoinGameRequest createRequest, SendParameters sendParameters, bool restored) { var gamePeer = (GameClientPeer)peer; byte?newMaxPlayer; bool?newIsOpen; bool?newIsVisible; object[] newLobbyProperties; Hashtable properties = createRequest.GameProperties; if (restored) { properties = Properties.GetProperties(); /// we set it to null in order to prevent property update in HandleJoinOperation createRequest.GameProperties = null; } SetupGameProperties(peer, createRequest, properties, ref sendParameters, out newMaxPlayer, out newIsOpen, out newIsVisible, out newLobbyProperties); Actor actor = this.HandleJoinOperation(peer, createRequest, sendParameters); if (actor == null) { return; } this.lobbyId = createRequest.LobbyName; this.lobbyType = (AppLobbyType)createRequest.LobbyType; if (log.IsDebugEnabled) { log.DebugFormat("CreateGame: name={0}, lobyName={1}, lobbyType={2}", this.Name, this.lobbyId, this.lobbyType); } // set default properties if (newMaxPlayer.HasValue && newMaxPlayer.Value != this.maxPlayers) { this.maxPlayers = newMaxPlayer.Value; } if (newIsOpen.HasValue && newIsOpen.Value != this.isOpen) { this.isOpen = newIsOpen.Value; } if (newIsVisible.HasValue && newIsVisible.Value != this.isVisible) { this.isVisible = newIsVisible.Value; } if (newLobbyProperties != null) { this.lobbyProperties = new HashSet <object>(newLobbyProperties); } // update game state at master server var peerId = gamePeer.PeerId ?? string.Empty; Hashtable gameProperties = this.GetLobbyGameProperties(properties); this.UpdateGameStateOnMaster(newMaxPlayer, newIsOpen, newIsVisible, newLobbyProperties, gameProperties, peerId); return; }
protected virtual void HandleCreateGameOperationBody(LitePeer peer, JoinGameRequest createRequest, SendParameters sendParameters, bool restored) { var gamePeer = (GameClientPeer)peer; byte? newMaxPlayer; bool? newIsOpen; bool? newIsVisible; object[] newLobbyProperties; Hashtable properties = createRequest.GameProperties; if (restored) { properties = Properties.GetProperties(); /// we set it to null in order to prevent property update in HandleJoinOperation createRequest.GameProperties = null; } SetupGameProperties(peer, createRequest, properties, ref sendParameters, out newMaxPlayer, out newIsOpen, out newIsVisible, out newLobbyProperties); Actor actor = this.HandleJoinOperation(peer, createRequest, sendParameters); if (actor == null) { return ; } this.lobbyId = createRequest.LobbyName; this.lobbyType = (AppLobbyType)createRequest.LobbyType; if (log.IsDebugEnabled) { log.DebugFormat("CreateGame: name={0}, lobyName={1}, lobbyType={2}", this.Name, this.lobbyId, this.lobbyType); } // set default properties if (newMaxPlayer.HasValue && newMaxPlayer.Value != this.maxPlayers) { this.maxPlayers = newMaxPlayer.Value; } if (newIsOpen.HasValue && newIsOpen.Value != this.isOpen) { this.isOpen = newIsOpen.Value; } if (newIsVisible.HasValue && newIsVisible.Value != this.isVisible) { this.isVisible = newIsVisible.Value; } if (newLobbyProperties != null) { this.lobbyProperties = new HashSet<object>(newLobbyProperties); } // update game state at master server var peerId = gamePeer.PeerId ?? string.Empty; Hashtable gameProperties = this.GetLobbyGameProperties(properties); this.UpdateGameStateOnMaster(newMaxPlayer, newIsOpen, newIsVisible, newLobbyProperties, gameProperties, peerId); return; }
public JoinRandomGameResponse JoinRandomGame(Hashtable gameProperties, byte maxPlayers, Hashtable actorProperties, MatchmakingMode mode, string lobbyName, AppLobbyType lobbyType, string sqlLobbyFilter, short errorCode = ErrorCode.Ok) { var request = new JoinRandomGameRequest { GameProperties = new Hashtable(), JoinRandomType = (byte)mode, LobbyType = (byte)lobbyType, LobbyName = lobbyName, }; if (maxPlayers > 0) { request.GameProperties.Add(GamePropertyKey.MaxPlayers, maxPlayers); } return(this.JoinRandomGame(request, errorCode)); }