// 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; }
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); }
protected GameListBase(AppLobby lobby) { this.Lobby = lobby; this.gameDict = new LinkedListDictionary<string, GameState>(); this.changedGames = new Dictionary<string, GameState>(); this.removedGames = new HashSet<string>(); }
protected GameListBase(AppLobby lobby) { this.Lobby = lobby; this.gameDict = new LinkedListDictionary <string, GameState>(); this.changedGames = new Dictionary <string, GameState>(); this.removedGames = new HashSet <string>(); }
public SqlGameList(AppLobby lobby) : base(lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new SqlGameList"); } }
public void Initialize() { this.defaultLobby = this.CreateAppLobby(string.Empty, defaultLobbyType); var defaultLobbyKey = new KeyValuePair <string, AppLobbyType>(string.Empty, defaultLobbyType); this.lobbyDict.Add(defaultLobbyKey, this.defaultLobby); }
public GameChannelList(AppLobby lobby) : base(lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new GameChannelList"); } }
public GameList(AppLobby lobby) : base(lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new GameList"); } }
// private int _limitSqlFilterResults; #endregion public SqlFilterGameList(AppLobby lobby, bool?useLegacyLobbies, int?limitSqlFilterResults, string matchmakingStoredProcedure) : base(lobby, limitSqlFilterResults, matchmakingStoredProcedure) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new SqlFilterGameList"); } _useLegacyLobbies = useLegacyLobbies ?? MasterServerSettings.Default.UseLegacyLobbies; }
public GameChannelList(AppLobby lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new GameChannelList"); } this.Lobby = lobby; this.GameDict = new Dictionary<string, GameState>(); }
public MasterClientPeer(InitRequest initRequest, AppLobby lobby) : base(initRequest.Protocol, initRequest.PhotonPeer) { this.lobby = lobby; if (MasterApplication.AppStats != null) { MasterApplication.AppStats.IncrementMasterPeerCount(); MasterApplication.AppStats.AddSubscriber(this); } }
/// <summary> /// Initializes a new instance of the <see cref = "GameState" /> class. /// </summary> /// <param name="lobby"> /// The lobby to which the game belongs. /// </param> /// <param name = "id"> /// The game id. /// </param> /// <param name = "maxPlayer"> /// The maximum number of player who can join the game. /// </param> /// <param name = "gameServerPeer"> /// The game server peer. /// </param> public GameState(AppLobby lobby, string id, byte maxPlayer, IncomingGameServerPeer gameServerPeer) { this.Lobby = lobby; this.Id = id; this.MaxPlayer = maxPlayer; this.IsOpen = true; this.IsVisible = true; this.IsCreatedOnGameServer = false; this.GameServerPlayerCount = 0; this.gameServer = gameServerPeer; }
public GameList(AppLobby lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new GameList"); } this.Lobby = lobby; this.gameDict = new LinkedListDictionary <string, GameState>(); this.changedGames = new Dictionary <string, GameState>(); this.removedGames = new HashSet <string>(); }
public SqlGameList(AppLobby lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new GameList"); } this.Lobby = lobby; this.gameDict = new LinkedListDictionary<string, GameState>(); this.changedGames = new Dictionary<string, GameState>(); this.removedGames = new HashSet<string>(); }
public LimitedGameList(AppLobby lobby, bool?useLegacyLobbies, int?limitGameList, int?limitGameListUpdate) : base(lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new LimitedGameList"); } _useLegacyLobbies = useLegacyLobbies ?? MasterServerSettings.Default.UseLegacyLobbies; _limitGameList = limitGameList ?? MasterServerSettings.Default.LimitGameList; _limitGameListUpdate = limitGameListUpdate ?? MasterServerSettings.Default.LimitGameListUpdate; }
public bool GetOrCreateGame(string gameId, AppLobby lobby, IGameList gameList, byte maxPlayer, IncomingGameServerPeer gameServerPeer, out GameState gameState) { lock (this.gameDict) { if (this.gameDict.TryGetValue(gameId, out gameState)) { return false; } gameState = new GameState(lobby, gameId, maxPlayer, gameServerPeer); this.gameDict.Add(gameId, gameState); return true; } }
/// <summary> /// Initializes a new instance of the <see cref = "GameState" /> class. /// </summary> /// <param name="lobby"> /// The lobby to which the game belongs. /// </param> /// <param name = "id"> /// The game id. /// </param> /// <param name = "maxPlayer"> /// The maximum number of player who can join the game. /// </param> /// <param name = "gsContext"> /// The game server peer. /// </param> public GameState(AppLobby lobby, string id, byte maxPlayer, GameServerContext gsContext) { this.Lobby = lobby; this.Id = id; this.MaxPlayer = maxPlayer; this.IsOpen = true; this.IsVisible = true; this.HasBeenCreatedOnGameServer = false; this.GameServerPlayerCount = 0; this.gameServerContext = gsContext; this.IsJoinable = this.CheckIsGameJoinable(); this.activeUserIdList = new List <string>(maxPlayer > 0 ? maxPlayer : 5); this.inactiveUserIdList = new List <string>(maxPlayer > 0 ? maxPlayer : 5); this.expectedUsersList = new List <string>(maxPlayer > 0 ? maxPlayer : 5); this.excludedActors = new List <ExcludedActorInfo>(); }
public SqlGameList(AppLobby lobby, int?limitSqlFilterResults, string matchmakingStoredProcedure = null) : base(lobby) { if (log.IsDebugEnabled) { log.DebugFormat("Creating new SqlGameList"); } _limitSqlFilterResults = limitSqlFilterResults ?? MasterServerSettings.Default.LimitSqlFilterResults; this.matchmakingStoredProcedure = matchmakingStoredProcedure; //do this in the AppLobby and pass dictionary to here? // TryLoadStoredProceduresFromFile(); TryLoadStoredProcedures(matchmakingStoredProcedure); }
private static GetLobbyStatsResponse LobbyListToLobbyStatsData(AppLobby[] lobbyList) { var lobbyStats = new GetLobbyStatsResponse(); var count = lobbyList.Length; lobbyStats.LobbyNames = new string[count]; lobbyStats.LobbyTypes = new byte[count]; lobbyStats.PeerCount = new int[count]; lobbyStats.GameCount = new int[count]; for (int i = 0; i < lobbyList.Length; i++) { var item = lobbyList[i]; lobbyStats.LobbyNames[i] = item.LobbyName; lobbyStats.LobbyTypes[i] = (byte)item.LobbyType; lobbyStats.PeerCount[i] = item.PeerCount + item.PlayerCount; lobbyStats.GameCount[i] = item.GameCount; } return lobbyStats; }
public GameState(AppLobby lobby, Hashtable data) { this.Lobby = lobby; this.Id = (string)data[GameId]; this.MaxPlayer = (byte)data[MaxPlayerId]; this.IsOpen = (bool)data[IsOpenId]; this.IsVisible = (bool)data[IsVisibleId]; this.InactivePlayerCount = (int)data[InactiveCountId]; this.createDateUtc = DateTime.FromBinary((long)data[CreateDateId]); this.activeUserIdList = new List <string>((string[])data[UserListId]); this.inactiveUserIdList = new List <string>((string[])data[InactiveUsersId]); this.expectedUsersList = new List <string>((string[])data[ExpectedUsersId]); this.excludedActors = new List <ExcludedActorInfo>((ExcludedActorInfo[])data[ExcludedUsersId]); this.properties = (Dictionary <object, object>)data[PropertiesId]; this.HasBeenCreatedOnGameServer = true; this.GameServerPlayerCount = 0; this.gameServerContext = null; this.IsJoinable = this.CheckIsGameJoinable(); }
public AppLobby[] GetLobbies(string[] lobbyNames, byte[] lobbyTypes) { if (lobbyNames.Length == 0) { return new AppLobby[0]; } var appLobbies = new AppLobby[lobbyNames.Length]; lock (this.lobbyDict) { for (int i = 0; i < lobbyNames.Length; i++) { var key = new KeyValuePair<string, AppLobbyType>(lobbyNames[i], (AppLobbyType)lobbyTypes[i]); AppLobby lobby; this.lobbyDict.TryGetValue(key, out lobby); appLobbies[i] = lobby; } } return appLobbies; }
public AppLobby[] GetLobbies(string[] lobbyNames, byte[] lobbyTypes) { if (lobbyNames.Length == 0) { return(new AppLobby[0]); } var appLobbies = new AppLobby[lobbyNames.Length]; lock (this.lobbyDict) { for (int i = 0; i < lobbyNames.Length; i++) { var key = new KeyValuePair <string, AppLobbyType>(lobbyNames[i], (AppLobbyType)lobbyTypes[i]); AppLobby lobby; this.lobbyDict.TryGetValue(key, out lobby); appLobbies[i] = lobby; } } return(appLobbies); }
// 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 bool TryCreateGame(string gameId, AppLobby lobby, IGameList gameList, byte maxPlayer, IncomingGameServerPeer gameServerPeer, out GameState gameState) { bool result = false; lock (this.gameDict) { if (this.gameDict.TryGetValue(gameId, out gameState) == false) { gameState = new GameState(lobby, gameId, maxPlayer, gameServerPeer); this.gameDict.Add(gameId, gameState); result = true; } } if (result) { if (log.IsDebugEnabled) { log.DebugFormat("Created game: gameId={0}, appId={1}", gameId, this.ApplicationId); } } return result; }
private OperationResponse TryGetLobby(string lobbyName, byte lobbyType, byte operationCode, out AppLobby lobby) { if (string.IsNullOrEmpty(lobbyName) && this.AppLobby != null) { lobby = this.AppLobby; return null; } if (!this.Application.LobbyFactory.GetOrCreateAppLobby(lobbyName, (AppLobbyType) lobbyType, out lobby)) { // getting here should never happen if (log.IsWarnEnabled) { log.WarnFormat("Could not get or create lobby: name={0}, type={1}", lobbyName, lobbyType); } return new OperationResponse { OperationCode = operationCode, ReturnCode = (short)ErrorCode.InternalServerError, DebugMessage = LBErrorMessages.LobbyNotExist, }; } return null; }
public AsyncRandomGameList(AppLobby lobby) : base(lobby) { }
public LobbyFactory(GameApplication application, AppLobbyType defaultLobbyType) { this.application = application; this.defaultLobby = new AppLobby(this.application, string.Empty, defaultLobbyType); }
/// <summary> /// Initializes a new instance of the <see cref = "GameState" /> class. /// </summary> /// <param name="lobby"> /// The lobby to which the game belongs. /// </param> /// <param name = "id"> /// The game id. /// </param> /// <param name = "maxPlayer"> /// The maximum number of player who can join the game. /// </param> /// <param name = "gameServerPeer"> /// The game server peer. /// </param> public GameState(AppLobby lobby, string id, byte maxPlayer, IncomingGameServerPeer gameServerPeer) { this.Lobby = lobby; this.Id = id; this.MaxPlayer = maxPlayer; this.IsOpen = true; this.IsVisible = true; this.HasBeenCreatedOnGameServer = false; this.GameServerPlayerCount = 0; this.gameServer = gameServerPeer; this.IsJoinable = this.CheckIsGameJoinable(); this.activeUserIdList = new List<string>(maxPlayer > 0 ? maxPlayer : 5); this.inactiveUserIdList = new List<string>(maxPlayer > 0 ? maxPlayer : 5); this.expectedUsersList = new List<string>(maxPlayer > 0 ? maxPlayer : 5); this.excludedActors = new List<ExcludedActorInfo>(); }
public GameState(AppLobby lobby, Hashtable data) { this.Lobby = lobby; this.Id = (string)data[GameId]; this.MaxPlayer = (int)data[MaxPlayerId]; this.IsOpen = (bool)data[IsOpenId]; this.IsVisible = (bool)data[IsVisibleId]; this.InactivePlayerCount = (int)data[InactiveCountId]; this.createDateUtc = DateTime.FromBinary((long)data[CreateDateId]); this.activeUserIdList = new List<string>((string[])data[UserListId]); this.inactiveUserIdList = new List<string>((string[])data[InactiveUsersId]); this.expectedUsersList = new List<string>((string[])data[ExpectedUsersId]); this.excludedActors = new List<ExcludedActorInfo>((ExcludedActorInfo[])data[ExcludedUsersId]); this.properties = (Dictionary<object, object>)data[PropertiesId]; this.HasBeenCreatedOnGameServer = true; this.GameServerPlayerCount = 0; this.gameServer = null; this.IsJoinable = this.CheckIsGameJoinable(); }
public void Initialize() { this.defaultLobby = this.CreateAppLobby(string.Empty, defaultLobbyType); var defaultLobbyKey = new KeyValuePair<string, AppLobbyType>(string.Empty, defaultLobbyType); this.lobbyDict.Add(defaultLobbyKey, this.defaultLobby); }
public MasterClientPeer(InitRequest initRequest, AppLobby lobby) : base(initRequest.Protocol, initRequest.PhotonPeer) { this.lobby = lobby; }