Skip to content

Instantly share code, notes, and snippets.

@jaouadballat
Created April 4, 2018 20:08
Show Gist options
  • Save jaouadballat/455aa46fd714a16511584d469e58ad36 to your computer and use it in GitHub Desktop.
Save jaouadballat/455aa46fd714a16511584d469e58ad36 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const server = app.listen(3001, function() {
console.log('server running on port 3001');
});
const io = require('socket.io')(server);
io.on('connection', function(socket) {
console.log(socket.id)
socket.on('SEND_MESSAGE', function(data) {
io.emit('MESSAGE', data)
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment