javascript - Detecting when a long request has ended in NodeJS / Express -



javascript - Detecting when a long request has ended in NodeJS / Express -

i'm dealing server-sent events, pseudo-code looks this:

var listeners = []; app.get('/stream', function (req, res) { listeners.push({ req: req, res: res }); }); // ... happens notify(listeners);

now works quite fine acutally, how know when client closes browser window don't run out of memory eventually? have manage client-side or there req.on('close', fn); can't find?

thanks in advance. :)

using request's close event should work fine:

var listeners = []; app.get('/stream', function (req, res) { var listener = { req: req, res: res }; listeners.push(listener); req.on('close', function() { listeners.splice(listeners.indexof(listener), 1); }); });

javascript node.js express server-sent-events

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -