コード例 #1
0
ファイル: AEGame.cs プロジェクト: ZoroChain/ApplicationEngine
        public bool onSessionCmd(ISession s, object sCtx, string cls, string method, object par)
        {
            AEPlayer p = null;

            if (!_players.TryGetValue(s.sessionID, out p))
            {
                s.lastErrorCode = AEErrorCode.ERR_SESSOIN_PLAYER_NOT_EXIST;
                s.lastErrorMsg  = "game [" + this.name + "] onSessionCmd sid [" + s.sessionID + "] player not exist!";
                Debug.logger.log(LogType.LOG_ERR, s.lastErrorMsg);
                return(false);
            }

            IGameModule m = getGameModule(cls);

            if (m == null)
            {
                if (this.name == "SHOutGame" && cls == "webGame")
                {
                    s.lastErrorCode = AEErrorCode.ERR_SESSION_NEED_LOGIN;
                    s.lastErrorMsg  = "need login!";
                }
                else
                {
                    s.lastErrorCode = AEErrorCode.ERR_SYS_SERVER_INTERNAL_ERROR;
                    s.lastErrorMsg  = "game [" + this.name + "] onSessionCmd sid [" + s.sessionID + "] game module[" + cls + "] not exist!";
                }
                if (method != "refreshUser" && method != "logout")
                {
                    Debug.logger.log(LogType.LOG_ERR, s.lastErrorMsg);
                }
                return(false);
            }

            return(m.onPlayerCmd(p, sCtx, method, par));
        }
コード例 #2
0
ファイル: AEGame.cs プロジェクト: ZoroChain/ApplicationEngine
        public IPlayer getPlayerByID(ulong id)
        {
            AEPlayer p = null;

            _players.TryGetValue(id, out p);
            return(p);
        }
コード例 #3
0
ファイル: AEGame.cs プロジェクト: ZoroChain/ApplicationEngine
        public void onAddSession(ISession s, string cls, string method, object par)
        {
            AEPlayer p = _newPlayer();

            p.init(s);

            _players[s.sessionID] = p;

            // initialize player
            foreach (var item in _modules)
            {
                item.Value.initPlayer(p);
            }
        }
コード例 #4
0
ファイル: AEGame.cs プロジェクト: ZoroChain/ApplicationEngine
        public void onSessionClose(ISession s, string cls, string method, object par)
        {
            AEPlayer p = null;

            if (!_players.TryGetValue(s.sessionID, out p))
            {
                Debug.logger.log(LogType.LOG_ERR, "game [" + this.name + "] onSessionClose sid [" + s.sessionID + "] player not exist!");
                return;
            }

            // TO DO : clear player

            // foreach(var item in _modules)
            // {
            //     item.Value.onRemovePlayer(p);
            // }

            // session close, need persist & clear db data
            p.flushAll(true);
            p.fin(true);

            _players.Remove(s.sessionID);
        }