"progress"

This commit is contained in:
codey 2024-09-18 09:45:45 -04:00
parent 5d68d132ae
commit 696266c3be
2 changed files with 9 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class ConnectionManager:
await self.broadcast({
"event": "client_connected",
"ts": str(time.time()),
"ts": int(time.time()),
"data": {
"connected_resource": handshakedClient.resource,
}

View File

@ -49,12 +49,19 @@ class CAH(FastAPI):
if data.get('event') == 'handshake':
await self.cah_handshake(websocket,
data)
else:
sender = self.connection_manager.get_connection_by_ws(websocket)
await self.connection_manager.broadcast({
"event": "echo",
"from": sender.get('client').resource,
"data": data,
})
except WebSocketDisconnect:
disconnected = self.connection_manager.get_connection_by_ws(websocket)
self.connection_manager.disconnect(websocket)
await self.connection_manager.broadcast({
"event": "client_disconnected",
"ts": time.time(),
"ts": int(time.time()),
"data": {
"disconnected_resource": disconnected.get('client').resource,
}