Exit when room closed.
[toast/stream2beamer.git] / lagarde.py
index 28cff738cbfc6377427af3ffa4c5cf208e70c301..487b88c43816a15a3744d4d218780c4ac64f7149 100755 (executable)
@@ -183,22 +183,24 @@ class Lagarde:
                 msg_json = json.loads(msg)
                 msg_type = msg_json['Type']
                 msg_value = msg_json['Value']
-                self.session_id = msg_json['SessionID']
                 log.info(f"receive for session {self.session_id} type {msg_type}")
                 if msg_type == 'newSession':
-                    pass
+                    self.session_id = msg_json['SessionID']
                 elif msg_type == 'gotOffer':
+                    assert self.session_id == msg_json['SessionID']
                     value_json = json.loads(msg_value)
                     sdp = value_json['sdp']
                     log.info(f'SDP: {sdp}')
                     self.sdp_offer = sdp
                 elif msg_type == 'addCallerIceCandidate':
+                    assert self.session_id == msg_json['SessionID']
                     value_json = json.loads(msg_value)
                     log.info(f'ICE: {value_json}')
                     self.received_ice_candidates.append(value_json)
                 elif msg_type == 'roomClosed':
                     log.info('Oh noes, the room went away!')
-                    # and here we should clean up
+                    self.session_id = None
+                    return
                 else:
                     log.error(f'Unknown message type {msg_type}')