Exemple #1
0
        /// <summary>
        /// 消息体的反序列化
        /// </summary>
        /// <param name="buff"></param>
        /// <returns></returns>
        public static SocketModel decode(byte[] buff)
        {
            MemoryStream ms    = new MemoryStream(buff);
            BinaryReader br    = new BinaryReader(ms);
            SocketModel  model = new SocketModel();

            model.Type    = br.ReadByte();
            model.Area    = br.ReadByte();
            model.command = br.ReadByte();
            byte[] result = br.ReadBytes((int)(ms.Length - ms.Position));
            if (result.Length != 0)
            {
                model.message = SerializeUtil.Derialize(result);
            }
            br.Close();
            ms.Close();
            return(model);
        }