Last active
June 20, 2018 10:34
-
-
Save amitkhare/537d6d77f36c363113b09e89ee93cb96 to your computer and use it in GitHub Desktop.
Express + 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 express = require('express'); | |
var app = express(); | |
var http = require('http').Server(app); | |
var io = require('socket.io')(http); | |
app.get('/', function(req, res){ | |
res.sendFile(__dirname + '/public/default.html'); | |
}) | |
app.use('/', express.static('public')); | |
io.on('connection', function(socket){ | |
console.log('a user connected'); | |
socket.on('disconnect', function(){ | |
console.log('user disconnected'); | |
}); | |
}); | |
http.listen(8080, function(){ | |
console.log('listening on *:8080'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment