My question is as follows: I would like to know what would be the best or at least a good way to pack and send data from client to server and the reverse. There will be a few data composing a single packet. A packet will have a "id", that defines what is it for, then the data in a pre- determined order for that "action" which the packet corresponds.
For less performance-dependant systems, i would just send strings, that would be separated by a space, being them the data of the "action"and the first "word" the packet identifier and just chain if statements checking when there is a match.
Now for a more critical system, what i tought so far was something like this:
Make a string with packet id and data, and send it. Then, to unpack, i could extract the first integer in the string, and by having an array of packet handlers, with indices corresponding to the packet id they handle, and just do something like packetHandlers[packetID].Process(packetData) .
What do you think of it, any suggestions? greatly apreciated!