Home Forums Support Serializing Objects Reply To: Serializing Objects

#483
Anonymous
Inactive

Kind of. Except that I have the following:

// Used as a header for all module packets
[ProtoContract]
public class ModulePacketHeader2
{
[ProtoMember(1)]
public string packetType { get; set; }

[ProtoMember(2)]
public string from { get; set; }

[ProtoMember(3)]
public string to { get; set; }

[ProtoMember(4)]
public Object data { get; set; }

private ModulePacketHeader2() { }

public ModulePacketHeader2(string packetType, string from, string to, Object data)
{
this.packetType = packetType;
this.from = from;
this.to = to;
this.data = data;
}
}

And I want to put the following object in the data field of above:

[ProtoContract]
public class ModulePacketType2_authResponse
{
[ProtoMember(1)]
public string authCode { get; set; }

private ModulePacketType2_authResponse() { }

public ModulePacketType2_authResponse(string authCode)
{
this.authCode = authCode;
}
}

 

The idea is that the “server” in the middle will get the entire packet (header (authResponse)) and look at the to field and then send it on to the client that the packet is for. But I get exceptions when I try to send above, because it does not know what “Object” is – which is why I tried doing what the website I linked to suggested (abstract and sealed class) which also gave me errors. Any ideas?