|
|
|
@ -21,19 +21,12 @@ async def websocket_handler(request):
|
|
|
|
await ws.prepare(request)
|
|
|
|
await ws.prepare(request)
|
|
|
|
asyncio.create_task(secondary_functions.time_response(ws, delay=60))
|
|
|
|
asyncio.create_task(secondary_functions.time_response(ws, delay=60))
|
|
|
|
async for msg in ws:
|
|
|
|
async for msg in ws:
|
|
|
|
|
|
|
|
|
|
|
|
if msg.type == aiohttp.WSMsgType.TEXT:
|
|
|
|
if msg.type == aiohttp.WSMsgType.TEXT:
|
|
|
|
|
|
|
|
|
|
|
|
if msg.data == 'close':
|
|
|
|
|
|
|
|
await ws.close()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
await ws.send_str(f'Вы ввели: {msg.data}')
|
|
|
|
await ws.send_str(f'Вы ввели: {msg.data}')
|
|
|
|
elif msg.type == WSMsgType.ERROR:
|
|
|
|
elif msg.type == WSMsgType.ERROR:
|
|
|
|
print('ws connection closed with exception %s' %
|
|
|
|
print('ws connection closed with exception %s' %
|
|
|
|
ws.exception())
|
|
|
|
ws.exception())
|
|
|
|
|
|
|
|
|
|
|
|
print('websocket connection closed')
|
|
|
|
print('websocket connection closed')
|
|
|
|
|
|
|
|
|
|
|
|
return ws
|
|
|
|
return ws
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|