public Protocol(ProtoID id, ProtoBody body) { protoHead = new ProtoHead(); protoHead.CmdID = id; serverHead = new ServerHead(); protoBody = body; }
/// <summary> /// 仅生成ProtoHead /// </summary> public Protocol() { protoHead = new ProtoHead(); serverHead = new ServerHead(); protoBody = null; }
/// <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); }
public static ProtoID GetProtoIDFromBytes(byte[] data, int dataLen) { if (dataLen < (GetNormalProtoHeadLen())) { return(null); } return(BitConverter.ToUInt16(data, ServerHead.GetSerializeLength())); }
public static int GetNormalProtoHeadLen() { return(ServerHead.GetSerializeLength() + ProtoHead.GetSerializeLength()); }