Skip to content

Commit c2a9ebd

Browse files
committed
SSE only accept clients when the expId is correct.
1 parent 91df807 commit c2a9ebd

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

HttpServer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ def SSE(self, expId=None):
4848
cherrypy.response.headers['Cache-Control'] = 'no-cache'
4949
cherrypy.response.headers['Connection'] = 'keep-alive'
5050
# TO DO: stop when all clients are disconnected
51-
if not self.control.running:
52-
self.control.start()
53-
return self.control.nextSample()
51+
if expId is not None:
52+
if expId in [e['id'] for e in self.experiences]:
53+
if not self.control.running:
54+
self.control.start()
55+
return self.control.nextSample()
56+
return 'event: CLOSE\n\n'
5457
SSE._cp_config = {'response.stream': True}
5558

5659
@cherrypy.expose

0 commit comments

Comments
 (0)