mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
add sending messages to server in web tool
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user