Colyseus — Minimalist MMO Game Server for Node.js

https://github.com/gamestdio/colyseus
// (client-side)
var Colyseus = new Colyseus("ws://localhost:3553");
var battleRoom = colyseus.join('battle', {options: 'here'})
// (server-side)
// only accept new users if limit isn't reached
requestJoin (options) {
return ( this.clients.length < 12 )
}
// (server-side)
onJoin (client) {
// setup new player here
}
// (client-side)
battleRoom.on('error', function(message) {
console.log("error triggered on battle room:", message)
})
// (client-side)
battleRoom.on('update', function(newState, patches) {
console.log(patches) // array of patches
console.log(newState) // newState with patches applied
})
[
{ "op": "remove", "path": "/players/N150OHMve" },
{ "op": "add", "path": "/players/NkfeqSGPx", "value": {"x": 10, "y": 10} },
{ "op": "replace", "path": "/players/NkfeqSGPx/x", "value": 5 }
]
// JSON-Patch Spec - RFC6902

Software Engineer & Indie Game Developer