HTML and CSS Reference
In-Depth Information
for (var arg in args) {
// Don't overwrite the message type
if (arg != "type")
msg[arg] = args[arg];
};
//return JSON.stringify(msg);
return BISON.encode(msg);
};
BiSON is similar in many respects to BSON and MessagePack; BiSON is more lightweight than JSON and can
more efficiently store types. However, BiSON lacks the mindshare of BSON and MessagePack. You can read more
Off-the-Shelf Solutions and WebSocket-likeProducts
When creating a game, you are not limited to pure WebSockets or a solution like
Socket.io
. There are several
technologies either similar to or based on WebSockets that can be used to create games.
Firebase
Firebase (
www.firebase.com
)
provides a real-time API for syncing and accessing data. Firebase has client libraries
and bindings for most mobile and web platforms, while offering the option of a Representational state transfer (REST)
API if your favorite language or framework is not supported. Firebase is somewhat like WebSockets plus a data store
wrapped up in the same package.
Firebase stores data in a JSON-like format, and it allows you to access the data through one of several options:
•
A client library
•
Vanilla REST calls
•
A browser
Everything that you store is addressable by its object path. For instance, consider a player object stored at the root
http://MyGame.firebaseIO-demo.com
and represented by the following code:
ud7h3if: {
name: 'John',
vitals: {
health: 80,
attack: 20,
weapons: ['pistol', 'rifle', 'machete']
}
}
You could display the object by navigating to
http://MyGame.firebaseIO-demo.com/ud7h3if
, or perhaps
http://MyGame.firebaseIO-demo.com/ud7h3if/vitals/weapons
, respectively.