[NodeJS] Lexical environment issues 07-05-2015, 01:56 AM
#1
Code:
router.post('/', function (req, res) {
// Need to send ws.send() with post data
})
wss.on('connection', function(ws) {
ws.on('message', function(message) {
console.log('r : %s', message);
});
// ws is only define under this callback as an object of type ws
});
ws is only defined within the wss connection event.
ws = WebSockets
router = default Express router
I've read a tiny amount about 'closures', but haven't fully read on them.
Any advice, guys?