fix voice rooms
This commit is contained in:
@ -9,18 +9,27 @@ async def voice_ws(
|
||||
room_id: str = Query(...),
|
||||
username: str = Query(...)
|
||||
):
|
||||
if username in voice_hub.rooms.get(room_id, {}):
|
||||
await ws.close(code=4001)
|
||||
return
|
||||
|
||||
await voice_hub.connect(room_id, username, ws)
|
||||
|
||||
# уведомим остальных
|
||||
await voice_hub.broadcast(
|
||||
users = list(voice_hub.rooms.get(room_id, {}).keys())
|
||||
await ws.send_json({
|
||||
"type": "users",
|
||||
"users": users
|
||||
})
|
||||
|
||||
await voice_hub.broadcast_except(
|
||||
room_id,
|
||||
username,
|
||||
{"type": "join", "user": username}
|
||||
)
|
||||
|
||||
try:
|
||||
while True:
|
||||
msg = await ws.receive_json()
|
||||
|
||||
if msg["type"] == "signal":
|
||||
await voice_hub.send_to(
|
||||
room_id,
|
||||
|
||||
Reference in New Issue
Block a user