Skip to content

Instantly share code, notes, and snippets.

@Njuelle
Created January 12, 2019 13:12
Show Gist options
  • Select an option

  • Save Njuelle/a867505daa100319ac029e9e6fd782bd to your computer and use it in GitHub Desktop.

Select an option

Save Njuelle/a867505daa100319ac029e9e6fd782bd to your computer and use it in GitHub Desktop.
Minimum NodeJS Socket.io server
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