Passing around objects to network packet handlers ?

Posted by xeross on Stack Overflow See other posts from Stack Overflow or by xeross
Published on 2010-05-02T22:19:24Z Indexed on 2010/05/02 22:38 UTC
Read the original article Hit count: 187

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about c++

Related posts about networking