+export async function processPeerAnswer({ peerId, answer }) {
+ const peerConnection = internals.peers[peerId];
+ const remoteDescription = new RTCSessionDescription(answer);
+ await peerConnection.setRemoteDescription(remoteDescription);
+}
+
+export async function addIceCandidate({ peerId, candidate }) {
+ const peerConnection = internals.peers[peerId];
+ const iceCandidate = new RTCIceCandidate(candidate);
+ await peerConnection.addIceCandidate(iceCandidate);
+}
+
+export function countPeers() {
+ return Object.keys(internals.peers).length;
+}
+
+export function resetPeers() {
+ internals.peers = {};
+ document
+ .querySelectorAll(".junction-call-audio")
+ .forEach((audioElement) => audioElement.remove());
+}