Web controls for Fire Platoon

We have decided to move the player controls off the touch table and onto individual web-enabled devices in Fire Platoon. There are a couple reasons for this decision. Most importantly, we didn’t have enough space to put even four player’s controls onto the screen and still have legible icons on the main map of the building. Second, we think that players will feel more connected to their in-game fire fighter if they are holding the controls in their hands. With off-screen controls, we can make the game map bigger and support more players (probably 8)

We are going to use web sockets to send messages between the game and the player’s web clients. Web sockets are now supported by all the web browsers, so anyone with a smartphone or tablet should be able to connect to the game and play without downloading an app.

We have been using mongoose 3.7 as our built-in web server. We have had a couple problems with it and we decided to upgrade to the latest version which is 5.2. There have been significant changes to how the web server operates. In 3.7 it used a thread pool to handle the connections, which limited the number of simultaneous connections (not really a problem for us), and forced us to pass data received from a client to the main thread for processing. Mongoose 5.2 uses asynchronous IO and has significantly better web socket handling. The new web socket interface allows us to detect when a client disconnects and to force a disconnect. We didn’t expect to see much performance difference, but we were pleasantly surprised that the new version connects quite a bit faster.

Integrating mongoose into Torque was significantly easier than the first time I did it, but it was significantly different because it needed to poll every tick and it consolidated many event handlers into one. If anyone is interested, here is the source code:

WebServer for Torque 2D

Note: this post was written 3/23/2014 and retroactively published to 2/13/2014 which is when I did the work.

Leave a Reply