per-message deflate compression fixes

This commit is contained in:
Benjamin Sergeant
2018-11-13 17:46:05 -08:00
parent e847716076
commit 54da891f79
4 changed files with 43 additions and 13 deletions

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python
import os
import asyncio
import websockets
connections = set()
async def echo(websocket, path):
connections.add(websocket)
try:
async for message in websocket:
print(message)
for ws in connections:
if ws != websocket:
await ws.send(message)
except:
raise
finally:
connections.remove(websocket)
asyncio.get_event_loop().run_until_complete(
websockets.serve(echo, 'localhost', 8080))
asyncio.get_event_loop().run_forever()