Skip to content

Instantly share code, notes, and snippets.

@shrekuu
Created June 28, 2018 10:55
Show Gist options
  • Select an option

  • Save shrekuu/be702ddbf491e42852c21616171ce4a3 to your computer and use it in GitHub Desktop.

Select an option

Save shrekuu/be702ddbf491e42852c21616171ce4a3 to your computer and use it in GitHub Desktop.
koajs + socket.io server side example
const Koa = require('koa');
const app = new Koa();
const server = require('http').createServer(app.callback());
const io = require('socket.io')(server, {path: '/remote-control-sockjs'});
const port = process.env.PORT || 8080;
server.listen(port);
io.on('connection', function (socket) {
socket.on('slide-change', function (detail) {
console.log(detail);
io.emit('slide-change', detail);
});
});
console.log('koa app running on http://localhost:' + port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment