onMessage (client, data) - When a client send a message
onDispose () - Cleanup callback, called after there's no more clients on the room
Available methods
setState( object ) - Set the current state to be broadcasted / patched.
setSimulationInterval( callback[, milliseconds=16.6] ) - (Optional) Create the simulation interval that will change the state of the game. Default simulation interval: 16.6ms (60fps)
setPatchRate( milliseconds ) - Set frequency the patched state should be sent to all clients. Default is 50ms (20fps).
useTimeline([ maxSnapshots=10 ]) - (Optional) Keep state history between broadcatesd patches.
send( client, data ) - Send data to a particular client.
lock() - Lock the room to new clients.
unlock() - Unlock the room to new clients.
broadcast( data ) - Send data to all connected clients.
disconnect() - Disconnect all clients then dispose.
Production usage
It's recommended to use a process manager to ensure the server will reload in
case your application goes down.
pm2 start server.js --node-args="--harmony"
Redirect port 80 to target deployment port (e.g. 3000), to avoid running harmful
code as sudoer: (read more)