Passing around objects to network packet handlers ?
- by xeross
Hey,
I've been writing a networking server for a while now in C++ and have come to the stage to start looking for a way to properly and easily handle all packets.
I am so far that I can figure out what kind of packet it is, but now I need to figure out how to get the needed data to the handler functions.
I had the following in mind:
Have a map of function pointers with the opcode as key and the function pointer as value
Have all these functions have 2 arguments, packet and ObjectAccessor
ObjectAccessor class contains various functions to fetch various items such as users and alike
Perhaps pass the user's guid too so we can fetch it from the objectaccessor
I'd like to know the various implementations others have come up with, so please comment on this idea and reply with your own implementations.
Thanks, Xeross