Skip to content

Instantly share code, notes, and snippets.

@dianevinson
Created June 17, 2020 20:42
Show Gist options
  • Save dianevinson/d10ce8f8b68b783ec3f62dd702580958 to your computer and use it in GitHub Desktop.
Save dianevinson/d10ce8f8b68b783ec3f62dd702580958 to your computer and use it in GitHub Desktop.
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var port = process.env.PORT || 3000;
app.get('/', function(request, response) {
response.sendFile(__dirname + '/views/index.html');
});
io.on('connection', function(socket){
console.log("hi");
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
});
var listener = http.listen(process.env.PORT, function() {
console.log('Your app is listening on port ' + listener.address().port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment