1.0.0 • Published 8 years ago

io-router v1.0.0

Weekly downloads
22
License
MIT
Repository
github
Last release
8 years ago

io-router

Easy routing for socket.io. Inspired by express.io way of routing socket.io.

How to use:

var app = require('express')();
var io = require('socket.io');

var server = app.listen('8080', function () {
    io = io(server)

    require('io-router')(io);
  
    io.route('dummy', function (req) {
        console.log(req.data);
    });
    
    io.route('john', {
        doe: function (req) {
            req.io.route('foo:bar:baz');  
        }
    });
    
    io.route('foo', {
        bar: {
            baz: function (req) {
                req.io.route('dummy')
            }
        }
    });

    io.on('connection', function (socket) {
        io.router.init(socket);
    });
});