/// <summary> /// Initializes a new instance of the <see cref="PacketMsg"/> class. /// </summary> /// <param name="eMsg">The network message type for this packet message.</param> /// <param name="data">The data.</param> public PacketMsg(EMsg eMsg, byte[] data) { MsgType = eMsg; payload = data; MsgHdr msgHdr = new MsgHdr(); // deserialize the header to get our hands on the job ids using (MemoryStream ms = new MemoryStream(data)) { msgHdr.Deserialize(ms); } TargetJobID = msgHdr.TargetJobID; SourceJobID = msgHdr.SourceJobID; }
/// <summary> /// Initializes a new instance of the <see cref="PacketMsg"/> class. /// </summary> /// <param name="eMsg">The network message type for this packet message.</param> /// <param name="data">The data.</param> public PacketMsg(EMsg eMsg, byte[] data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } MsgType = eMsg; payload = data; Header = new MsgHdr(); // deserialize the header to get our hands on the job ids using MemoryStream ms = new MemoryStream(data); Header.Deserialize(ms); BodyOffset = ms.Position; }
/// <summary> /// Initializes a new instance of the <see cref="PacketMsg"/> class. /// </summary> /// <param name="eMsg">The network message type for this packet message.</param> /// <param name="data">The data.</param> public PacketMsg(EMsg eMsg, byte[] data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } MsgType = eMsg; payload = data; MsgHdr msgHdr = new MsgHdr(); // deserialize the header to get our hands on the job ids using (MemoryStream ms = new MemoryStream(data)) { msgHdr.Deserialize(ms); } TargetJobID = msgHdr.TargetJobID; SourceJobID = msgHdr.SourceJobID; }