Пример #1
0
 public Protocol(ProtoID id, ProtoBody body)
 {
     protoHead       = new ProtoHead();
     protoHead.CmdID = id;
     serverHead      = new ServerHead();
     protoBody       = body;
 }
Пример #2
0
        /// <summary>
        /// 仅生成ProtoHead
        /// </summary>
        public Protocol()
        {
            protoHead  = new ProtoHead();
            serverHead = new ServerHead();

            protoBody = null;
        }
Пример #3
0
        /// <summary>
        /// 生成ProtoHead,ServerHead,ProtoID,并使用传入的ProtoBody赋值
        /// </summary>
        /// <param name="bodyIn"></param>
        public Protocol(ProtoBody bodyIn)
        {
            protoHead  = new ProtoHead();
            serverHead = new ServerHead();
            protoBody  = bodyIn;

            protoHead.CmdID = ProtoID.GetProtoIDByBody(bodyIn);
        }
Пример #4
0
        public static ProtoID GetProtoIDFromBytes(byte[] data, int dataLen)
        {
            if (dataLen < (GetNormalProtoHeadLen()))
            {
                return(null);
            }

            return(BitConverter.ToUInt16(data, ServerHead.GetSerializeLength()));
        }
Пример #5
0
 public static int GetNormalProtoHeadLen()
 {
     return(ServerHead.GetSerializeLength() + ProtoHead.GetSerializeLength());
 }