add sending messages to server in web tool

This commit is contained in:
Ziad-I
2024-06-13 17:41:51 +03:00
committed by Dion Moult
parent 88610e23b2
commit 467602aec3
+14 -8
View File
@@ -96,6 +96,18 @@ class Web(blenderbim.core.tool.Web):
print("Webserver terminated successfully")
@classmethod
def send_webui_data(cls):
global ws_thread
data = cls.get_webui_data()
ws_thread.run_coro(cls.sio_send(data))
@classmethod
def get_webui_data(cls):
data = {}
data["ifc_file"] = bpy.context.scene.BIMProperties.ifc_file
return json.dumps(data)
@classmethod
async def sio_connect(cls, url):
await sio.connect(url, transports=["websocket"], namespaces="/blender")
@@ -110,8 +122,8 @@ class Web(blenderbim.core.tool.Web):
await sio.disconnect()
@classmethod
async def sio_send(cls, message):
await sio.emit("data", {"from": "client"}, namespace="/blender")
async def sio_send(cls, data):
await sio.emit("data", data, namespace="/blender")
@classmethod
def set_is_running(cls, is_running):
@@ -121,12 +133,6 @@ class Web(blenderbim.core.tool.Web):
def set_is_connected(cls, is_connected):
bpy.context.scene.WebProperties.is_connected = is_connected
@classmethod
def get_webui_data(cls):
data = {}
data["ifc_file"] = bpy.context.scene.BIMProperties.ifc_file
return json.dumps(data)
class AsyncioThread(threading.Thread):
def __init__(self, *args, loop=None, **kwargs):