]> git.r.bdr.sh - rbdr/junction/blobdiff - extension/peers.js
Fix typo in CONTRIBUTING
[rbdr/junction] / extension / peers.js
index be494b0ca477793f747c2c49415235b4afdc7c19..5ba5c487b20533ba1c0cbb3f76e5c1056c2fe793 100644 (file)
@@ -13,7 +13,13 @@ const internals = {
   },
 };
 
-export function addPeer({ peerId, shouldCreateOffer, mediaStream, onOffer, socket }) {
+export function addPeer({
+  peerId,
+  shouldCreateOffer,
+  mediaStream,
+  onOffer,
+  socket,
+}) {
   const peerConnection = new RTCPeerConnection(
     { iceServers: internals.kIceServers },
     { optional: [{ DtlsSrtpKeyAgreement: true }] },
@@ -92,6 +98,9 @@ export function countPeers() {
 }
 
 export function resetPeers() {
+  for (const connection of Object.values(internals.peers)) {
+    connection.close();
+  }
   internals.peers = {};
   document
     .querySelectorAll(".junction-call-audio")