MCPcopy
hub / github.com/aio-libs/aiohttp / wshandler

Function wshandler

tests/autobahn/server.py:9–30  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

7
8@asyncio.coroutine
9def wshandler(request):
10 ws = web.WebSocketResponse(autoclose=False)
11 ok, protocol = ws.can_start(request)
12 if not ok:
13 return web.HTTPBadRequest()
14
15 yield from ws.prepare(request)
16
17 while True:
18 msg = yield from ws.receive()
19
20 if msg.tp == web.MsgType.text:
21 ws.send_str(msg.data)
22 elif msg.tp == web.MsgType.binary:
23 ws.send_bytes(msg.data)
24 elif msg.tp == web.MsgType.close:
25 yield from ws.close()
26 break
27 else:
28 break
29
30 return ws
31
32
33@asyncio.coroutine

Callers

nothing calls this directly

Calls 6

can_startMethod · 0.95
prepareMethod · 0.95
receiveMethod · 0.95
send_strMethod · 0.95
send_bytesMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected