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

Function dispatch

websockets/chat-tcp/client.py:28–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

start_clientFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected