Created
June 17, 2020 20:42
-
-
Save dianevinson/d10ce8f8b68b783ec3f62dd702580958 to your computer and use it in GitHub Desktop.
This file contains 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 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