![]() |
|
[NodeJS] Lexical environment issues - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Design (https://sinister.ly/Forum-Design) +--- Forum: Web Design (https://sinister.ly/Forum-Web-Design) +--- Thread: [NodeJS] Lexical environment issues (/Thread-NodeJS-Lexical-environment-issues) |
[NodeJS] Lexical environment issues - lux - 07-05-2015 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? RE: [NodeJS] Lexical environment issues - leen12 - 07-20-2015 i have no idea about coding really but im geussing anyone that does would need a bit more info RE: [NodeJS] Lexical environment issues - lux - 07-21-2015 (07-20-2015, 11:42 PM)leen12 Wrote: i have no idea about coding really but im geussing anyone that does would need a bit more info Nope. Used Events to get around it. |