webrtc/signalling: Give a helpful error when starting a double-session
authorNirbheek Chauhan <nirbheek@centricular.com>
Mon, 12 Dec 2022 14:39:00 +0000 (20:09 +0530)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 12 Dec 2022 15:08:23 +0000 (15:08 +0000)
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>

subprojects/gst-examples/webrtc/signalling/simple_server.py

index cb42591..9eab742 100755 (executable)
@@ -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')