working websocket server
This commit is contained in:
7
test.py
7
test.py
@@ -14,14 +14,14 @@ async def handshake(ws,j):
|
||||
async def set_variable(j):
|
||||
for name,ws in clients.get(j.get('project_id'),{}).items():
|
||||
print(f"> {name} - {json.dumps(j)}")
|
||||
ws.send(json.dumps(j))
|
||||
await ws.send(json.dumps(j))
|
||||
|
||||
async def disconnect(project_id,user):
|
||||
print("disconnecting",user)
|
||||
clients.get(project_id,[]).pop(user)
|
||||
|
||||
|
||||
async def hello(websocket, path):
|
||||
async def process(websocket, path):
|
||||
project_id = ""
|
||||
user = ""
|
||||
async for data in websocket:
|
||||
@@ -36,7 +36,6 @@ async def hello(websocket, path):
|
||||
pass
|
||||
await disconnect(project_id,user)
|
||||
|
||||
start_server = websockets.serve(hello, 'localhost', 5000)
|
||||
|
||||
start_server = websockets.serve(process, 'localhost', 5000, compression=None)
|
||||
asyncio.get_event_loop().run_until_complete(start_server)
|
||||
asyncio.get_event_loop().run_forever()
|
||||
Reference in New Issue
Block a user