How To Have Multiple Clients Listen To A Server Sent Event?
I am trying to get my head around server sent events. The rest of my site is served using cherrypy, so I want to get them working on this platform too. The method I'm using to expo
Solution 1:
Apparently I shouldn't be using a Queue
. So I just needed to cut down my code to:
@cherrypy.expose
def interlocked(self, _=None):
cherrypy.response.headers["Content-Type"] = "text/event-stream;charset=utf-8"
if _:
data = 'retry: 400\ndata: ' + str(self.isInterlocked) + '\n\n'
return data
else:
def content():
data = 'retry: 400\ndata: ' + str(self.isInterlocked) + '\n\n'
return data
return content()
interlocked._cp_config = {'response.stream': True, 'tools.encode.encoding':'utf-8'}
Post a Comment for "How To Have Multiple Clients Listen To A Server Sent Event?"