Exemple #1
0
        public virtual bool TryCreateGame(string gameId, AppLobby lobby, byte maxPlayer, GameServerContext gameServer, out GameState gameState, out ErrorCode errorCode, out string errorMsg)
        {
            bool result = false;

            errorCode = ErrorCode.Ok;
            errorMsg  = string.Empty;

            lock (this.gameDict)
            {
                if (this.gameDict.TryGetValue(gameId, out gameState) == false)
                {
                    gameState = new GameState(lobby, gameId, maxPlayer, gameServer);
                    this.gameDict.Add(gameId, gameState);
                    result = true;
                }
            }

            if (result)
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Created game: gameId={0}, appId={1}", gameId, this.ApplicationId);
                }
            }
            else
            {
                errorCode = ErrorCode.GameIdAlreadyExists;
                errorMsg  = LBErrorMessages.GameAlreadyExist;
            }

            return(result);
        }
 public GameChannelList(AppLobby lobby)
     : base(lobby)
 {
     if (log.IsDebugEnabled)
     {
         log.DebugFormat("Creating new GameChannelList");
     }
 }
Exemple #3
0
        public GameChannelList(AppLobby lobby)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Creating new GameChannelList");
            }

            this.Lobby    = lobby;
            this.GameDict = new Dictionary <string, GameState>();
        }
        public bool GetOrCreateGame(string gameId, AppLobby lobby, 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);
            }
        }
        public bool TryCreateGame(string gameId, AppLobby lobby, 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);
        }
Exemple #7
0
 public bool GetOrCreateGame(string gameId, AppLobby lobby, byte maxPlayer, GameServerContext gameServer, out GameState gameState, out ErrorCode errorCode, out string errorMsg)
 {
     return(this.TryCreateGame(gameId, lobby, maxPlayer, gameServer, out gameState, out errorCode, out errorMsg));
 }