Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C++] Serializing packets

Newbie Spellweaver
Joined
Aug 14, 2015
Messages
79
Reaction score
18
Thanks for the reply. I already have a packet handling system with a simple function pointer array (handlers[opcode](params)) so execute function might be inapplicable. I'm not sure which one is better though, having the factory inside the base class or basically having an external factory which would take required data and return a NetworkMessage which is basically an std::vector<unsigned char> . Second option would save me from writing all those derived classes(considering there're over a 100 packets it feels second option might have an advantage).
 
Newbie Spellweaver
Joined
Jul 31, 2015
Messages
39
Reaction score
33
Obiective programming is about beauty, and extensibility. To add new packet all you do is create new implementation (yes there will be a LOT of derived classes but also the same ammount of them in any other way of handling it) and add it to factory. Tell me about your handlers[opcode](params). What if one packet sends a single int (lets say, quest ID accepted), and other packet sends a 3 ints (xyz update)? In C++ it impossible to create array of function pointers with different ammount/type of arguments, how do you solve the issue? If u cast, then its bad already. Take a look at java implementation of packet handling in Lineage2 server. It is decent:

Greetz
 
Newbie Spellweaver
Joined
Aug 14, 2015
Messages
79
Reaction score
18
Parameters aren't packet specific. Packet data is dissolved within handlers. Handler prototypes are simply like: handler(iocp_sock, protocol, msg).
 
Back
Top