Multiplayer game server framework for Node.js
npm install patchwirenpm install patchwire
JavaScript
// MyGameServer.js
const Server = require('patchwire').Server;
const ClientManager = require('patchwire').ClientManager;
const gameLobby = new ClientManager();
gameLobby.on('clientAdded', function() {
gameLobby.broadcast('chat', {
message: 'A new player has joined the game.'
});
});
const server = new Server(function(client) {
gameLobby.addClient(client);
});
server.listen(3001);
`
Documentation
See the patchwire Github wiki
About
Patchwire is a server framework designed for multiplayer games. Originally built to work with GameMaker: Studio's networking code, it has been standardized to be unassuming about the client end framework.
Patchwire uses a paradigm of sending "commands" to clients, and in turn, listening for commands from the client. A command is nothing more than a string identifier, and some data. A command looks like this:
`JavaScript
{
command: 'updatePosition',
x: 200,
y: 120
}
``