Spaces:
Paused
Paused
Daniel Marques
commited on
Commit
•
03ebafe
1
Parent(s):
a455f54
fix: add callback
Browse files
main.py
CHANGED
@@ -246,10 +246,11 @@ async def websocket_endpoint(websocket: WebSocket, client_id: int):
|
|
246 |
|
247 |
i = 0
|
248 |
for item in pubsub.listen():
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
253 |
i+=1
|
254 |
|
255 |
|
|
|
246 |
|
247 |
i = 0
|
248 |
for item in pubsub.listen():
|
249 |
+
if item["type"] == "message":
|
250 |
+
message = item["data"].decode('utf-8')
|
251 |
+
if message == "end": pubsub.unsubscribe({client_id})
|
252 |
+
if(i == 10): pubsub.unsubscribe({client_id})
|
253 |
+
await websocket.send_text(f'{message}')
|
254 |
i+=1
|
255 |
|
256 |
|