Skip to content

Instantly share code, notes, and snippets.

@fieldAbyss
Last active March 4, 2018 05:11
Show Gist options
  • Save fieldAbyss/6777c03afe76d86d20f5d9a092588912 to your computer and use it in GitHub Desktop.
Save fieldAbyss/6777c03afe76d86d20f5d9a092588912 to your computer and use it in GitHub Desktop.
# Using with Express 3/4 ES6 .ver URL:github-gist
const app = require('express')();
const server = require('http').Server(app);
const io = require('socket.io')(server);
server.listen(80);
app.get('/', (req, res) => {
res.sendfile(__dirname + '/index.html');
});
io.on('connection', (socket) => {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment