Наследование: ISteamSerializableHeader
		static ISteamSerializableHeader ReadHeader(uint rawEMsg, Stream stream)
		{
			ISteamSerializableHeader header;

			if (MsgUtil.IsProtoBuf(rawEMsg))
			{
				header = new MsgHdrProtoBuf();
			}
			else
			{
				switch (rawEMsg)
				{
					case (uint)EMsg.ChannelEncryptRequest:
					case (uint)EMsg.ChannelEncryptResponse:
					case (uint)EMsg.ChannelEncryptResult:
						header = new MsgHdr();
						break;

					default:
						header = new ExtendedClientMsgHdr();
						break;
				}
			}

			header.Deserialize(stream);
			return header;
		}
Пример #2
0
		public void GetPacketMsgReturnsPacketMsgForCryptoHandshake()
		{
			var messages = new[]
			{
				EMsg.ChannelEncryptRequest,
				EMsg.ChannelEncryptResponse,
				EMsg.ChannelEncryptResult
			};

			foreach(var emsg in messages)
			{
				var msgHdr = new MsgHdr { Msg = emsg };

				var data = Serialize(msgHdr);

				var packetMsg = CMClient.GetPacketMsg(data);
				Assert.IsAssignableFrom<PacketMsg>(packetMsg);
			}
		}
Пример #3
0
        /// <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;
        }