Skip to content

Commit

Permalink
SSE only accept clients when the expId is correct.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsombria committed Nov 12, 2019
1 parent 91df807 commit c2a9ebd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions HttpServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ def SSE(self, expId=None):
cherrypy.response.headers['Cache-Control'] = 'no-cache'
cherrypy.response.headers['Connection'] = 'keep-alive'
# TO DO: stop when all clients are disconnected
if not self.control.running:
self.control.start()
return self.control.nextSample()
if expId is not None:
if expId in [e['id'] for e in self.experiences]:
if not self.control.running:
self.control.start()
return self.control.nextSample()
return 'event: CLOSE\n\n'
SSE._cp_config = {'response.stream': True}

@cherrypy.expose
Expand Down

0 comments on commit c2a9ebd

Please sign in to comment.