コード例 #1
0
        private void OnClientReceive(TcpSocketAsync client, byte[] data, int length)
        {
            byte[]  buffer = this.OnDecrypt(data);
            MsgData msg    = MsgData.Deserialize(buffer);

            if (msg != null)
            {
                try
                {
                    if (cmdCallbackDic.ContainsKey(msg.Cmd))
                    {
                        var callModel = cmdCallbackDic[msg.Cmd];
                        this.ExecCall(callModel, client, msg);
                        return;
                    }
                    else
                    {
                        msg.Rest();
                        msg.Status = MsgStatus.Unknown;
                        this.SendMsg(msg, client.UserState as Session);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    this.OnMvcHostServerErrorEvent(ex);
                }
            }
            else
            {
                this.OnMvcHostServerErrorEvent(new Exception(string.Format("client({0}): msg is null!", client.RemoteEndPoint.ToString())));
            }
        }