Home Forums Support Serializing Objects Reply To: Serializing Objects

#486
Anonymous
Inactive

Just want to clarify more.. Basically the Server will only look at the packet header. It will very rarely if ever care about what is in the Data field (hence it being an object). Right now I have two clients (they are called modules) and will be adding more clients in the future. There will be a few packets that the server will respond to, but it will not respond to most packets other than looking at the from and to field and then relaying the entire message to the client it’s for.

So there could be 100 different packet types, with each being a class. All packets will use the same header. Out of the 100, the server would only have to recognize maybe 2 or 3 – those are packets for modules to authorize against the server – so that way the server knows the module is legit and vice versa. And I will be adding in more packet types all the time as I write new modules (clients) that will communicate through the system. And the last thing I want to do is to have to update the server for every single packet type that I add.

That is why AppendGlobalIncomingPacketHandler T (String, NetworkComms PacketHandlerCallBackDelegate T ) does not work for me on the server side. I would have to add one for every single packet, plus write an individual function for that specific packet type. I also looked at the source code, there is no “if this packet does not have a handler, send it to a function for generic packets”.

For the clients, I will be using AppendGlobalIncomingPacketHandler – its invaluable – because I can have the clients ignore all packets that they cant handle and I can call specific functions for each kind of packet. Perfect, makes my life a lot easier. Not so much for the server part though.

So my options are one of the following for the server:

1.) Figure out how to do what I explained two posts ago and use abstract/sealed classes or other way to allow Protobuf to serialize it. I already got this working using Binary Serialization but it’s a lot slower and the server will be handling A LOT of traffic, so I cannot have any choke points. And that way I can use AppendGlobalIncomingPacketHeader for ModulePacketHeader.
2.) Modify the source code to add in a new callback that I can then hook to – that way if a packet does not match anything in the GlobalIncomingPacket list – it will call my function with the packet code. I will also modify my protocol so that way I wont use PackeHeader for every packet – I would put the to and from fields into every packetType so it will work with protobuf.

3.) Find another way to do this.

I’ll be doing some more research today on Protobuf as well as tinkering with Sealed/Abstract classes. If anybody can help me with this, I would appreciate it a lot.

Sorry for the long post. I re-read the past few posts I made and I felt I didn’t clarify as much as I should have.