Created
December 8, 2015 14:58
-
-
Save chanakaDe/c051b63135e76459f6dc to your computer and use it in GitHub Desktop.
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 app = require('express')(); | |
var server = require('http').Server(app); | |
var io = require('socket.io')(server); | |
server.listen(8080, function (err) { | |
if (err) { | |
console.error(err); | |
} else { | |
console.log("Server listening on port 8080"); | |
} | |
}); | |
app.get('/operateLight', function (req, res) { | |
var light = req.param('lightVal'); | |
console.log(light); | |
res.json({light_value: light}); | |
}); | |
io.on('connection', function (socket) { | |
socket.emit('light1', {status: light}); | |
socket.on('my other event', function (data) { | |
console.log(data); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment