This commit is contained in:
Guy Van Sanden 2025-02-12 11:41:45 +01:00
parent 62e7468eb2
commit e364c7d965

View File

@ -29,12 +29,12 @@ def sendmessage(target, message):
json_command = json.dumps(command) json_command = json.dumps(command)
""" Connects to WebSocket server, sends a message, and returns the response """ """ Connects to WebSocket server, sends a message, and returns the response """
uri = "ws://localhost:5080" # uri = "ws://localhost:5080"
ws = websocket.create_connection(uri) # Blocking WebSocket connection # ws = websocket.create_connection(uri) # Blocking WebSocket connection
ws.send(json_command) # Send message to WebSocket ws.send(json_command) # Send message to WebSocket
responsejson = ws.recv() # Receive response responsejson = ws.recv() # Receive response
response = json.loads(responsejson) response = json.loads(responsejson)
ws.close() # ws.close()
for chatitem in response['resp']['chatItems']: for chatitem in response['resp']['chatItems']:
statusdict = chatitem['chatItem']['meta']['itemStatus'] statusdict = chatitem['chatItem']['meta']['itemStatus']
@ -49,6 +49,10 @@ def sendmessage(target, message):
print("Message '%s' sent over websocket to %s, status was %s" % (smessage, target, status)) print("Message '%s' sent over websocket to %s, status was %s" % (smessage, target, status))
if status == 'complete': if status == 'complete':
if smessage != message:
print("Sent duplicate message, FAIL")
return False
else:
return True return True
else: else:
return False return False
@ -79,5 +83,5 @@ def webhook_receiver(id):
if __name__ == '__main__': if __name__ == '__main__':
print("Started %s" % (versionstring)) print("Started %s" % (versionstring))
uri = "ws://localhost:5080" uri = "ws://localhost:5080"
# ws = websocket.create_connection(uri) ws = websocket.create_connection(uri)
app.run() app.run()