Shit to res.close listener
This commit is contained in:
1 parent
195f18659d
commit
1bd64b397f
3 files changed
+27
-47
No files matched your search
@@ -12,13 +12,12 @@ app.get('/api/stream/:id', (req, res)=>{
|
||||
'Connection' : 'keep-alive',
|
||||
'Content-Encoding' : 'none'
|
||||
});
|
||||
;
|
||||
Stream.subscribe(req.params.id, res, req.query?.client);
|
||||
});
|
||||
|
||||
app.get('/api/stream/unsubscribe/:id', (req, res)=>{
|
||||
Stream.unsubscribe(req.params?.id);
|
||||
res.status(200).send();
|
||||
const subId = Stream.subscribe(req.params.id, res);
|
||||
|
||||
res.on('close', ()=>{
|
||||
Stream.unsubscribe(subId);
|
||||
});
|
||||
});
|
||||
|
||||
export default app;
|
||||
Reference in new issue
Block a user