This commit is contained in:
Guy Van Sanden 2025-02-12 11:42:36 +01:00
parent e364c7d965
commit 8fa91e5e5f

View File

@ -12,6 +12,7 @@ versionstring='Taurix TellMe server v' + __version__
app = Flask(__name__)
lock = threading.Lock()
ws = None
hooks = {}
with open(r'/etc/tellme/hooks.yml') as hooksfile:
@ -29,8 +30,10 @@ def sendmessage(target, message):
json_command = json.dumps(command)
""" Connects to WebSocket server, sends a message, and returns the response """
# uri = "ws://localhost:5080"
# ws = websocket.create_connection(uri) # Blocking WebSocket connection
if ws is None:
uri = "ws://localhost:5080"
ws = websocket.create_connection(uri) # Blocking WebSocket connection
ws.send(json_command) # Send message to WebSocket
responsejson = ws.recv() # Receive response
response = json.loads(responsejson)