diff --git a/src/client/cli.py b/src/client/cli.py index ae0d7ae..074ebe1 100644 --- a/src/client/cli.py +++ b/src/client/cli.py @@ -2,6 +2,7 @@ import websocket import _thread import time import ssl +import yaml def on_message(ws, message): print(f"<< {message}") @@ -24,11 +25,18 @@ def on_open(ws): ws.close() _thread.start_new_thread(run, ()) -if __name__ == "__main__": +def open_socket(url, port): websocket.enableTrace(True) - ws = websocket.WebSocketApp("ws://localhost:6873", + ws = websocket.WebSocketApp(f"ws://{url}:{port}", on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close) ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}) + + +if __name__ == "__main__": + with open('config.yaml', 'r') as f: + conf = yaml.safe_load(f) + open_socket(conf['ws']['url'], conf['ws']['port']) + diff --git a/src/client/test_config.yaml b/src/client/test_config.yaml new file mode 100644 index 0000000..23ac0a0 --- /dev/null +++ b/src/client/test_config.yaml @@ -0,0 +1,3 @@ +ws: + url: localhost + port: 6873