SteamKit2.Internal.MsgGCHdrProtoBuf.Deserialize C# (CSharp) Method

Deserialize() public method

public Deserialize ( Stream stream ) : void
stream Stream
return void
		public void Deserialize( Stream stream )
		{
			BinaryReader br = new BinaryReader( stream );

			Msg = MsgUtil.GetGCMsg( (uint)br.ReadUInt32() );
			HeaderLength = br.ReadInt32();
			using( MemoryStream msProto = new MemoryStream( br.ReadBytes( HeaderLength ) ) )
				Proto = ProtoBuf.Serializer.Deserialize<SteamKit2.GC.Internal.CMsgProtoBufHeader>( msProto );
		}
	}

Usage Example

Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PacketClientGCMsgProtobuf"/> class.
        /// </summary>
        /// <param name="eMsg">The network message type for this packet message.</param>
        /// <param name="data">The data.</param>
        public PacketClientGCMsgProtobuf( uint eMsg, byte[] data )
        {
            MsgType = eMsg;
            payload = data;

            MsgGCHdrProtoBuf protobufHeader = new MsgGCHdrProtoBuf();

            // 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.job_id_target;
            SourceJobID = protobufHeader.Proto.job_id_source;
        }