0.2.0 • Published 11 years ago

socketron v0.2.0

Weekly downloads
4
License
-
Repository
github
Last release
11 years ago

O hapless Github wanderer: this is but a work in progress.

Socketron

A state machine for routing sockets and stuff.

Motivation

I found when working with socket.io, that:

io.sockets.on('connection', function (socket) {
  socket.on('this', function (...) { ... });
  socket.on('that', function (...) { ... });
  socket.on('the other thing', function (...) { ... });
  // ...
});

Didn't scale very well. Organization became difficult, and much spaghetti code ensued.

Install

Install with npm:

npm install socketron

Use

Give it a socket.io instance and you're good to go!

Examples

var io = require('socket.io').listen(80);
var socketron = require('socketron');

socketron(io)
.state('lobby', {
  default: true, // this is where newly connected sockets go
  on: {

  }
})
.state('game', {
  
});

License

MIT

0.2.0

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago