Esempio n. 1
0
        public void Execute(PacketBodyBase requestPacketBody, ReceivedSocketState receivedSocketState)
        {
            LoginResponse _response  = null;
            string        _exception = string.Empty;

            try
            {
                var _request = (LoginRequest)requestPacketBody;
                _response = this.CheckLogin(_request);
            }
            catch (Exception ex)
            {
                _response = new LoginResponse
                {
                    Status  = false,
                    Message = ResponseMessage.COMM_NETWORK_ERROR,
                };
                _exception = ex.ToString();
            }

            try
            {
                receivedSocketState.Response(PacketUtil.Pack(_response));
                Logger.LogInfo(string.Format("收到来自{0}的请求,Request = {1},Response = {2},Exception = {3}"
                                             , receivedSocketState.ClientIpAddress, requestPacketBody.ToString(), _response.ToString(), _exception));
            }
            catch (Exception ex)
            {
                throw new ResponseException(ex.ToString());
            }
        }
Esempio n. 2
0
        public void Execute(PacketBodyBase requestPacketBody, ReceivedSocketState receivedSocketState)
        {
            try
            {
                var _request  = (RegisterRequest)requestPacketBody;
                var _response = this.CheckRegister(_request);

                Logger.LogInfo(string.Format("收到来自{0}的注册请求,处理结果:{1}", receivedSocketState.ClientIpAddress, _response.Message));
                receivedSocketState.Response(PacketUtil.Pack(_response));
            }
            catch (Exception ex)
            {
                Logger.LogError(string.Format("收到来自{0}的注册请求,处理失败,错误信息:{1}", receivedSocketState.ClientIpAddress, ex));
                var _response = new RegisterResponse
                {
                    Status  = false,
                    Message = "网络异常,请重试!"
                };
                receivedSocketState.Response(PacketUtil.Pack(_response));
            }
        }