Last active
July 2, 2018 16:27
-
-
Save claytonbez/943332068231e02293ae9d13fd5da32e to your computer and use it in GitHub Desktop.
Socket.io Server example
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'); | |
var server = http.createServer(app); | |
var io = require('socket.io')(server); | |
app.use("/", express.static(__dirname + "/public")); | |
app.get("/", function (req, res) { | |
res.sendFile(__dirname + '/index.html'); | |
}); | |
io.on('connection',function(socket){ | |
console.log('Connected : ',socket.id); | |
socket.on('disconnect',function(){ | |
console.log('Disconnected :',socket.id); | |
}); | |
}); | |
server.listen(80,function(){ | |
console.log('ITNet Server Running on port 80'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment