async def test_commands(websocket):
- commands = [{'target': 'Example State', 'command': 'set state', 'state': True},
- {'target': 'Example State', 'command': 'get state'}]
+ commands = [{'target': 'Example State',
+ 'command': 'set state', 'state': True},
+ {'target': 'Example State', 'command':
+ 'get state'}]
for command in commands:
message = json.dumps(command)
await websocket.send(message)
await asyncio.sleep(0.1)
print("Wait for 1.9 seconds for delayed messages.")
await asyncio.sleep(1.9)
- async with websockets.connect(f"ws://localhost:8080/Example-Client") as websocket:
+ async with websockets.connect(f"ws://localhost:8080/Example-Client")\
+ as websocket:
print("Sending commands to websocket 'Example-Client'.")
command_task = asyncio.create_task(test_commands(websocket))
print("Receiving messages from the websocket.")