fix theme data not being sent when all Bonsai's are disconnected

This commit is contained in:
Ziad-I
2024-08-25 17:50:26 +03:00
parent c042d1afe5
commit 1745a4fd39
@@ -38,9 +38,9 @@ class WebNamespace(socketio.AsyncNamespace):
async def on_connect(self, sid, environ):
print(f"Web client connected: {sid}")
await sio.emit("theme_data", blender_theme, namespace="/web", room=sid)
if blender_messages:
await sio.emit("connected_clients", list(blender_messages.keys()), namespace="/web", room=sid)
await sio.emit("theme_data", blender_theme, namespace="/web", room=sid)
await self.send_cached_messages(sid)
async def on_disconnect(self, sid):
@@ -71,6 +71,7 @@ class WebNamespace(socketio.AsyncNamespace):
if "demo_data" in messages:
await self.emit("demo_data", {"blenderId": blenderId, "data": messages["demo_data"]}, room=sid)
# Blender namespace
class BlenderNamespace(socketio.AsyncNamespace):
def __init__(self, namespace):
@@ -115,8 +116,7 @@ class BlenderNamespace(socketio.AsyncNamespace):
blender_theme = data
await sio.emit("theme_data", data, namespace="/web")
# this function will be called when the event demo_data is emitted
# this function will be called when the event demo_data is emitted
async def on_demo_data(self, sid, data):
print(f"Demo data from Blender client {sid}")
blender_messages[sid]["demo_data"] = data