JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/webrtc-adapter/3.1.0/adapter_no_global.js"></script>
JavaScript
var iceServers = [
]
var config = {
iceServers: iceServers,
iceTransportPolicy: "all",
rtcpMuxPolicy: 'negotiate'
};
var pcConstraints = {};
var offerOptions = {offerToReceiveAudio: true};
pcConstraints.optional = [{'googIPv6': true}]; // Whether we gather IPv6 candidates.
var pc = new RTCPeerConnection(config, pcConstraints);
pc.onicecandidate = iceCallback;
pc.createOffer(
offerOptions
).then(
gotDescription,
error
);
function gotDescription(desc) {
console.log("OFFER DESC:", desc);
pc.setLocalDescription(desc);
}
function error() {
console.log("sth goes wrong", arguments);
}
function iceCallback(event) {
console.log("ICE!", JSON.stringify(event.candidate));
}