Our game relies on a lot of data being sent to and from the server. The data is serialized into JSON before it is transmitted over the wire.

Instead of handcrafting the packets by hand for each request, we have a generic system that allows us to keep the logic that deals with serialization centralized. This happens in our SerializationUtility and GameProperty classes. We define our own types that can be transmitted, and for each of those we implement a way to serialize it. Any time we need to transmit data, we pack it in one of those properties.

To make this easier to use and nest, we wrap these GameProperty instances in a PropertyCollection class which is a key-value store that identifies each property by a string name. Any class implementing the IPropertyHolder interface will contain a PropertyCollection that is exposed. Server Events, Actions, Game Entities, and Entity Info are all examples of property holders.

This approach, however, poses a challenge. Since the client and server need to both agree on the property names and what they mean, the key used on both sides must always match. This also makes it easy to break one side if the key is changed or a typo is made on one side but not the other. So to address this, we rely on decorators (called wrappers) that provide properties that encapsulate the key name and any special handling needed. These wrappers are shared between the server and client, thus ensuring both remain in sync all the time. We should never access a property directly by its key except in the wrapper classes.



Author Lotus
Views 82

Comments (1)

Comments are closed.

War to the Core

Recent Comments

Latest Updates

  • Solo missions

    Solo missions

    Hey guys, here are the specifics of the first two solo missions, those are sketches of the first two missions. First mission: A harvester is placed near the ship, generating supply caches. The player collects energy caches and escapes a ring of mines. No supply links allowed. The sensor component is introduced by one of […]Read More »
  • We made it to the Top 100!

    We made it to the Top 100!

    We are stoked that we managed to land on IndieDB’s Indie of the Year’s Top 100 list! We are also the only MOBA that made it to the list! The support we got from the community was overwhelming, and we would like to thank each and every person that helped us get this far. Whether […]Read More »
  • Full Campaign Series, Version 3

    Full Campaign Series, Version 3

    Characters: Daniel Blaze. Protagonist, player-character. Headstrong and rebellious. Ambiguous loyalty to the Shepherd Coalition. Joseph Blaze. Father of Daniel Blaze. Commander of the Leviathan mothership until executed for treason by the Shepherd Coalition. Sylvia. AI assistant. Provides intel, advice, mission objectives. Captain Zhukov. Cyborg commander assigned to hunt down player during the first several missions. […]Read More »
  • Story: Episode 1, Version 2

    Story: Episode 1, Version 2

    The Blaze family had long been controversial. They supported the Shepherds, but continually frustrated the Orthodox elements of their faction. Joseph Blaze was especially known for his tolerance of the weakling families that used genetic engineering to alleviate the sicknesses that exposure to the Earth’s surface had inflicted on them. Such tensions between orthodoxy and […]Read More »
  • Story: Episode 1

    Story: Episode 1

    Location: The Pole Base. When Daniel Blaze passed his final test and became the primary candidate to pilot the Leviathan, the Shepherds’ newest ship, he caused a quite a stir. Not because he’s the youngest member of the Pole fleet to be nominated for admiralship, the faction had already made peace with this as a […]Read More »
Skip to toolbar