Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -48,14 +48,14 @@ async def handle_client(websocket, path):
|
|
48 |
await websocket.send(f"You are paired with {other_client_address}")
|
49 |
|
50 |
# Create a bidirectional bridge
|
51 |
-
|
52 |
-
asyncio.ensure_future(bridge_clients(websocket, other_client))
|
53 |
-
asyncio.ensure_future(bridge_clients(other_client, websocket))
|
54 |
|
55 |
except websockets.exceptions.ConnectionClosed:
|
56 |
pass # Connection closed, handle appropriately
|
57 |
|
58 |
-
async def bridge_clients(source,
|
|
|
|
|
59 |
try:
|
60 |
while True:
|
61 |
# Receive data from the source client
|
|
|
48 |
await websocket.send(f"You are paired with {other_client_address}")
|
49 |
|
50 |
# Create a bidirectional bridge
|
51 |
+
asyncio.ensure_future(bridge_clients(websocket, other_client_address))
|
|
|
|
|
52 |
|
53 |
except websockets.exceptions.ConnectionClosed:
|
54 |
pass # Connection closed, handle appropriately
|
55 |
|
56 |
+
async def bridge_clients(source, destination_address):
|
57 |
+
destination = next(c for c in connected_clients if str(c.remote_address) == destination_address)
|
58 |
+
|
59 |
try:
|
60 |
while True:
|
61 |
# Receive data from the source client
|