Exemple #1
0
        /// <summary>
        /// 服务器启动
        /// </summary>
        protected override void Setup()
        {
            Instance = this;

            InitLog();
            LogInfo("服务器开启");

            InitHandler();
            InitSkill();
            LogInfo("初始化完成");
        }
Exemple #2
0
        /// <summary>
        /// 处理客户端请求
        /// </summary>
        /// <param name="operationRequest"></param>
        /// <param name="sendParameters"></param>
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            BaseHandler handler = MobaServer.Instance.HandlerDict.ExTryGet((OperationCode)operationRequest.OperationCode);

            if (handler != null)
            {
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
            else
            {
                MobaServer.LogError(">>>>>>>>> 找不到请求的对应处理 : " +
                                    Enum.GetName(typeof(OperationCode), operationRequest.OperationCode));
            }
        }
Exemple #3
0
        /// <summary>
        /// 客户端断开连接
        /// </summary>
        /// <param name="reasonCode"></param>
        /// <param name="reasonDetail"></param>
        protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
        {
            if (Username != null)
            {
                // 这里下线的顺序 要从内到外
                Caches.Battle.Offline(this);
                Caches.Select.Offline(this);
                Caches.Match.Offline(this);
                Caches.Player.Offline(this);
                Caches.User.Offline(Username);

                MobaServer.LogInfo("客户端断开, Username : "******"未知客户端断开");
            }
        }