Last active
March 4, 2018 05:11
-
-
Save fieldAbyss/6777c03afe76d86d20f5d9a092588912 to your computer and use it in GitHub Desktop.
# Using with Express 3/4 ES6 .ver URL:github-gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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