github.com/pion/webrtc/v3@v3.2.24/examples/ice-single-port/index.html (about) 1 <html> 2 <!-- 3 SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 4 SPDX-License-Identifier: MIT 5 --> 6 <head> 7 <title>ice-single-port</title> 8 </head> 9 10 <body> 11 <h3> ICE Selected Pairs </h3> 12 <div id="iceSelectedPairs"></div> <br /> 13 </body> 14 15 <script> 16 let createPeerConnection = () => { 17 let pc = new RTCPeerConnection() 18 let dc = pc.createDataChannel('data') 19 20 dc.onopen = () => { 21 let el = document.createElement('template') 22 let selectedPair = pc.sctp.transport.iceTransport.getSelectedCandidatePair() 23 24 el.innerHTML = `<div> 25 <ul> 26 <li> <i> Local</i> - ${selectedPair.local.candidate}</li> 27 <li> <i> Remote</i> - ${selectedPair.remote.candidate} </li> 28 </ul> 29 </div>` 30 31 document.getElementById('iceSelectedPairs').appendChild(el.content.firstChild); 32 } 33 34 pc.createOffer() 35 .then(offer => { 36 pc.setLocalDescription(offer) 37 38 return fetch(`/doSignaling`, { 39 method: 'post', 40 headers: { 41 'Accept': 'application/json, text/plain, */*', 42 'Content-Type': 'application/json' 43 }, 44 body: JSON.stringify(offer) 45 }) 46 }) 47 .then(res => res.json()) 48 .then(res => pc.setRemoteDescription(res)) 49 .catch(alert) 50 } 51 52 for (i = 0; i < 10; i++) { 53 createPeerConnection() 54 } 55 </script> 56 </html>