Minimalistic MMO Game Server for Node.js.
Live demos:
- WebSocket-based communication
- Match-making
- Binary data transfer (through msgpack)
- Delta-encoded state broadcasts (through fast-json-patch - RFC6902)
TODO:
- delay/lag compensation
- "area of interest" updates/broadcasts
- onJoin (client) - when a client joins the room
- onLeave (client) - when a client leaves the room
- onMessage (client, data) - when a client send a message
- dispose () - cleanup callback, called after there's no more clients on the room
- lock() - lock the room to new clients
- unlock() - unlock the room to new clients
- send(client, data) - send data to a particular client
- broadcast(data) - send data to all connected clients
- sendState(client) - send current state to a particular client
- broadcastState() - send current state to all clients
- broadcastPatch() - send patched (diff) state to all clients (called automatically at configurable interval)
- disconnect() - disconnect all clients then dispose
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)
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
MIT