From 249832e153f0592fc73a2bd4e3d4acc6767c698d Mon Sep 17 00:00:00 2001 From: michael-grace Date: Sun, 15 Nov 2020 17:48:05 +0000 Subject: [PATCH] some human readability --- server.py | 1 + templates/server.html | 3 +++ websocket_server.py | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 0cb4187..58fcee4 100644 --- a/server.py +++ b/server.py @@ -156,6 +156,7 @@ def restart_server(): state.update("host", request.form["host"]) state.update("port", int(request.form["port"])) state.update("num_channels", int(request.form["channels"])) + state.update("ws_port", int(request.form["ws_port"])) stopServer(restart=True) startServer() diff --git a/templates/server.html b/templates/server.html index c006006..7726c92 100644 --- a/templates/server.html +++ b/templates/server.html @@ -14,6 +14,9 @@
+ + +
{% endif %} diff --git a/websocket_server.py b/websocket_server.py index d744f21..8944d50 100644 --- a/websocket_server.py +++ b/websocket_server.py @@ -4,11 +4,12 @@ import json baps_clients = set() channel_to_q = None +server_name = None async def websocket_handler(websocket, path): baps_clients.add(websocket) - await websocket.send(json.dumps({"message": "Hello"})) + await websocket.send(json.dumps({"message": "Hello", "serverName": server_name})) print("New Client: {}".format(websocket)) try: @@ -47,6 +48,9 @@ class WebsocketServer: global channel_to_q channel_to_q = in_q + global server_name + server_name = state.state["server_name"] + websocket_server = websockets.serve(websocket_handler, state.state["host"], state.state["ws_port"]) asyncio.get_event_loop().run_until_complete(websocket_server)