Created
January 12, 2019 13:12
-
-
Save Njuelle/a867505daa100319ac029e9e6fd782bd to your computer and use it in GitHub Desktop.
Minimum NodeJS Socket.io server
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
| var io = require('socket.io')(1337); | |
| console.log('Socket listen on port 1337 : '); | |
| io.on('connection', socket => { | |
| console.log('Client connected'); | |
| socket.on('message', msg => { | |
| console.log(`New message : ${msg}`); | |
| }); | |
| socket.on('disconnect', () => { | |
| console.log('Client disconnected'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment