express-socket.io-router

1.0.5 • Public • Published

express-socket.io-router

Express-like routing interface for Socket.IO

Build Status

Install

npm install --save express-socket.io-router

Usage

Server

const SocketIO = require('socket.io');
const ExpressSocketIO = require('express-socket.io-router');
 
var io = new SocketIO(8080);
ExpressSocketIO(io);
 
io.register('test:path', function(req, res, next){
    console.log('request:', req.query, req.socket);
    res.send({
        query: req.query
    });
    next();
});

Client

const SocketIOClient = require('socket.io-client');
 
client = SocketIOClient.connect('http://localhost:8080');
client.emit('test:path', { data: 'test' }, function(err, res){
    console.log('response:', res);
});

Readme

Keywords

Package Sidebar

Install

npm i express-socket.io-router

Weekly Downloads

1

Version

1.0.5

License

Apache-2.0

Last publish

Collaborators

  • vpalmisano