I am working on a system where I need to create a protocol to help communicate data back and forth. Im curious how you guys have tackled this in the past:
My protocol packet looks something like this:
enum class Command
{
Authorize, //used to authorize a user
Version, //used to get the version of the client.
VersionR //used as the rversion reply.
};
template
class Packet
{
Command cmd;
int flag;
int length;
P* payload;;
};
Now for all of the data, the P is the payload. So for example:
class Authorization
{
const char* name;
const char* password;
};
The length of the payload can be retrieved and set as the length in the packet class. Is this something how people have implemented them in the past?