WebsoketSend / app.py
clone3's picture
Update app.py
9b1afb5
raw
history blame
779 Bytes
import asyncio
import websockets
async def hello():
uri = "ws://localhost:8765"
async with websockets.connect(uri) as websocket:
#messages = ["{"data":["spider",1683852825,8,4,true],"event_data":null,"fn_index":2,"session_hash":"kb46puzhzr"}", "Second message"]
messages = [
'{"fn_index":2,"session_hash":"kb46puzhzr"}',
'{"data":["spider",1683852825,8,4,true],"event_data":null,"fn_index":2,"session_hash":"kb46puzhzr"}'
]
for message in messages:
print(f"Sending: {message}")
await websocket.send(message)
response = await websocket.recv()
print(f"Received: {response}")
if __name__ == "__main__":
asyncio.run(hello())