Files
python-ai-video/test/wsc.py
2024-09-27 01:10:21 +08:00

24 lines
487 B
Python

import asyncio
import socketio
sio = socketio.AsyncClient()
@sio.event
async def connect():
print('connection established')
@sio.event
async def my_message(data):
print('message received with ', data)
await sio.emit('my response', {'response': 'my response'})
@sio.event
async def disconnect():
print('disconnected from server')
async def main():
await sio.connect('http://localhost:8000')
await sio.wait()
if __name__ == '__main__':
asyncio.run(main())