Inheritance: 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;
		}
Beispiel #2
0
		public void GetPacketMsgReturnsPacketClientMsgProtobufForMessagesWithProtomask()
		{
			var msg = MsgUtil.MakeMsg(EMsg.ClientLogOnResponse, protobuf: true);
			var msgHdr = new MsgHdrProtoBuf { Msg = msg };

			var data = Serialize(msgHdr);
			var packetMsg = CMClient.GetPacketMsg(data);
			Assert.IsAssignableFrom<PacketClientMsgProtobuf>(packetMsg);
		}
Beispiel #3
0
        public void GetPacketMsgFailsWithNull()
        {
            var msg = MsgUtil.MakeMsg(EMsg.ClientLogOnResponse, protobuf: true);
            var msgHdr = new MsgHdrProtoBuf { Msg = msg };

            var data = Serialize(msgHdr);
            Array.Copy(BitConverter.GetBytes(-1), 0, data, 4, 4);
            var packetMsg = CMClient.GetPacketMsg(data);
            Assert.Null(packetMsg);
        }
		static ISteamSerializableHeader ReadHeader(uint rawEMsg, Stream stream)
		{
			ISteamSerializableHeader header;

			if (MsgUtil.IsProtoBuf(rawEMsg))
			{
				header = new MsgHdrProtoBuf();
			}
			else
			{
				header = new ExtendedClientMsgHdr();
			}

			header.Deserialize(stream);
			return header;
		}
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PacketClientMsgProtobuf"/> class.
        /// </summary>
        /// <param name="eMsg">The network message type for this packet message.</param>
        /// <param name="data">The data.</param>
        public PacketClientMsgProtobuf( EMsg eMsg, byte[] data )
        {
            MsgType = eMsg;
            payload = data;

            MsgHdrProtoBuf protobufHeader = new MsgHdrProtoBuf();

            // we need to pull out the job ids, so we deserialize the protobuf header
            using ( MemoryStream ms = new MemoryStream( data ) )
            {
                protobufHeader.Deserialize( ms );
            }

            TargetJobID = protobufHeader.Proto.jobid_target;
            SourceJobID = protobufHeader.Proto.jobid_source;
        }
Beispiel #6
0
        ISteamSerializableHeader BuildHeader( uint realEMsg, Stream str )
        {
            ISteamSerializableHeader hdr = null;

            if ( MsgUtil.IsProtoBuf( realEMsg ) )
            {
                hdr = new MsgHdrProtoBuf();
            }
            else
            {
                hdr = new ExtendedClientMsgHdr();
            }

            hdr.Deserialize( str );
            return hdr;
        }