I have been spending a considerable amount of time adding proper websocket communication to Firmament Wars, including a special server push implementation that allows me to push game data updates in realtime from the server to the client. In addition, I used ZeroMQ to implement “PubSub” or, in other words, a way for a client to subscribe to specific communications they are interested in.
The most simple example of this is a way to change chat channels within a game. On the Firmament Wars title screen, you default to the Global chat channel, but if you type /channel cool_guys_only, you will be routed to the cool_guys_only channel, indeed. There you can discuss all of your top secret strategies without fear of compromising national security.
This is something that I always wanted to implement simply because it takes me back to the good old days of Starcraft and Diablo 2. I always liked how those games implemented their social environment and I always wanted to create something similar. I can say that I am very happy with how it’s working, though I am still relying on some long polling to assist with presence detection of the players. Server push is great for sending data to tons of people via channels, but I still couldn’t figure out a way to determine who was present within the channel. Server push is kind of like listening to a radio station. You have a ton of people listening to a single source of data. Thus, long polling is still used, though to a much lesser extent. This should reduce database strain significantly—so it’s a victory for sure!
Next, I will be working on implementing server push in the lobby and within the game itself. Websockets and server push will help the game not only scale much better, but it will also make the updates much faster since there is no laggy interval between each poll.