MCPcopy Create free account
hub / github.com/actix/examples / dispatch

Function dispatch

websockets/echo/websocket-client.py:24–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22 loop.add_reader(sys.stdin.fileno(), stdin_callback)
23
24 async def dispatch():
25 while True:
26 msg = await ws.receive()
27
28 if msg.type == aiohttp.WSMsgType.TEXT:
29 print('Text: ', msg.data.strip())
30 elif msg.type == aiohttp.WSMsgType.BINARY:
31 print('Binary: ', msg.data)
32 elif msg.type == aiohttp.WSMsgType.PING:
33 await ws.pong()
34 elif msg.type == aiohttp.WSMsgType.PONG:
35 print('Pong received')
36 else:
37 if msg.type == aiohttp.WSMsgType.CLOSE:
38 await ws.close()
39 elif msg.type == aiohttp.WSMsgType.ERROR:
40 print('Error during receive %s' % ws.exception())
41 elif msg.type == aiohttp.WSMsgType.CLOSED:
42 pass
43
44 break
45
46 await dispatch()
47

Callers 1

start_clientFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected