some human readability
This commit is contained in:
parent
79cd706253
commit
249832e153
3 changed files with 9 additions and 1 deletions
|
@ -156,6 +156,7 @@ def restart_server():
|
||||||
state.update("host", request.form["host"])
|
state.update("host", request.form["host"])
|
||||||
state.update("port", int(request.form["port"]))
|
state.update("port", int(request.form["port"]))
|
||||||
state.update("num_channels", int(request.form["channels"]))
|
state.update("num_channels", int(request.form["channels"]))
|
||||||
|
state.update("ws_port", int(request.form["ws_port"]))
|
||||||
stopServer(restart=True)
|
stopServer(restart=True)
|
||||||
startServer()
|
startServer()
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
<label for="channels">Number of Channels:</label>
|
<label for="channels">Number of Channels:</label>
|
||||||
<input type="number" id="channels" name="channels" class="form-control" value="{{data.state.num_channels}}">
|
<input type="number" id="channels" name="channels" class="form-control" value="{{data.state.num_channels}}">
|
||||||
<br>
|
<br>
|
||||||
|
<label for="port">WebSockets Port:</label>
|
||||||
|
<input type="number" id="ws_port" name="ws_port" class="form-control" value="{{data.state.ws_port}}">
|
||||||
|
<br>
|
||||||
<input type="submit" class="btn btn-primary" value="Restart Server">
|
<input type="submit" class="btn btn-primary" value="Restart Server">
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -4,11 +4,12 @@ import json
|
||||||
|
|
||||||
baps_clients = set()
|
baps_clients = set()
|
||||||
channel_to_q = None
|
channel_to_q = None
|
||||||
|
server_name = None
|
||||||
|
|
||||||
|
|
||||||
async def websocket_handler(websocket, path):
|
async def websocket_handler(websocket, path):
|
||||||
baps_clients.add(websocket)
|
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))
|
print("New Client: {}".format(websocket))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -47,6 +48,9 @@ class WebsocketServer:
|
||||||
global channel_to_q
|
global channel_to_q
|
||||||
channel_to_q = in_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"])
|
websocket_server = websockets.serve(websocket_handler, state.state["host"], state.state["ws_port"])
|
||||||
|
|
||||||
asyncio.get_event_loop().run_until_complete(websocket_server)
|
asyncio.get_event_loop().run_until_complete(websocket_server)
|
||||||
|
|
Loading…
Reference in a new issue