webrtc/signalling: Give a helpful error when starting a double-session

If the peer is already in a session and tries to start a new one, give
them a helpful error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2460>
This commit is contained in:
Nirbheek Chauhan 2022-12-12 20:09:00 +05:30 committed by GStreamer Marge Bot
parent 1e5abde7b1
commit 7fd8e4001c

View file

@ -161,7 +161,13 @@ class WebRTCSimpleServer(object):
if callee_id not in self.peers:
await ws.send('ERROR peer {!r} not found'.format(callee_id))
continue
if self.peers[callee_id][2] is not None:
if peer_status is not None:
await ws.send('ERROR you are already in a session, reconnect '
'to the server to start a new session, or use'
'a ROOM for multi-peer sessions')
continue
callee_status = self.peers[callee_id][2]
if callee_status is not None:
await ws.send('ERROR peer {!r} busy'.format(callee_id))
continue
await ws.send('SESSION_OK')