I am making a game and have it working quite well, except I haven't implemented multiplayer. I read all the networking tutorials, and I have made and successfully tested a few network programs.
One thing i'm not sure about is how to go about solving this problem:
If I want to send different types of messages, like one to update the position of an object, and another message to create a new object at (coords), how do I tell the receiver to correctly interpret the message as one or the other, because different scenarios require different types of data.
The solution I thought of was to have a sf::Packet, with a char at the front(I chose char because it's small), and depending on the value of the char, the receiver would attempt to extract the data that goes along with that indicated type, psuedo code being:
Recieve packet;
packet >> char;
if(char == 0)
packet >> int;
if(char == 1)
packet >> other types of data;
if(char == 2)
packet >> more data to do other things;
Also, can I get any smaller than a char?