Serialization of network messages for the game

Exit games create a network library product called photon, and they have and are actively developing a limited demonstration of MMO. Instead of shooting json or XML, etc., Saying "MovePlayer" (with the appropriate parameters), they quench this message up to 2 digits of int, through an enumeration - something like Operations.MovePlayer. There is no denying that a 2-digit int is smaller than a long string, however I really hate the idea of ​​statically burning each message to an enumeration.

Would there be an alternative way to have the MessageID property assign a unique 2-digit int based on a lookup table or something else? Has anyone done this before?

+4
source share
2 answers

For games, this is not an "old school" capable of doing things - this is the norm.

This is due to the fact that, unlike typical web services, where the server will send short client data, rare packets, in games, the server and client constantly send packets back and forth. The number of packets needed to synchronize each client state with each other balloon exponentially with the number of players, so the more players your game will have, the more important that the packet size is small.

In addition, switching to the MTU size (usually around 1400 bytes) will result in packet fragmentation, which can significantly affect performance.

Please note that Microsoft has a download and download limit of 8 kilobytes per second for games made for the XBox 360, so you can’t pretty much create an MMO using XML for network messaging.


How to translate a byte into a message type: just use the switch or save Dictionary<byte, Type> or Dictionary<byte, Func<Message>> (assuming you have a bunch of message classes that all come from the base Message class)

+3
source

This is a really old-fashioned way of doing things and reminds me of the 80s.

My company uses Agatha (a request broker) for messaging in our MMO:

http://davybrion.com/blog/2009/11/hello-world-with-agatha/

+1
source

Source: https://habr.com/ru/post/1333428/


All Articles