コード例 #1
0
        /// <summary>
        /// 消息体序列化
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static byte[] encode(object value)
        {
            SocketModel model = value as SocketModel;
            ByteArray   ba    = new ByteArray();

            ba.write(model.type);
            ba.write(model.area);
            ba.write(model.command);
            //判断消息体是否为空  不为空则序列化后写入
            if (model.message != null)
            {
                ba.write(SerializeUtil.encode(model.message));
            }
            byte[] result = ba.getBuff();
            ba.Close();
            return(result);
        }