Public
Edited
Apr 8
1 star
Insert cell
Insert cell
Insert cell
Insert cell
configuration = {
return {
iceServers: [
// { urls: "turn:freestun.net:3478", username: "free", credential: "free" }
{ urls: "stun:stun.l.google.com:19302" },
{
urls: "turn:turn.speed.cloudflare.com:50000",
username:
"73a69c5847f725b6f7f76802a817f16c47e1da1080c3957d1f4781ee54997021404551406a0ad0509ad3b481492f57063adb364fcb8d8d81bba95d05ec966ebf",
credential:
"aba9b169546eb6dcc7bfb1cdf34544cf95b5161d602e3b5fa7c8342b2e9802fb"
}
]
// rtcpMuxPolicy: 'require'
};
}
Insert cell
localConnection = new RTCPeerConnection(configuration)
Insert cell
Insert cell
JSON.stringify(localConnection.localDescription)
Insert cell
localConnection.onicecandidate = (e) => console.log("New ICE Candidate found. Current SDP:\n", localConnection.localDescription)
Insert cell
dataChannel = {
const dataChannel = localConnection.createDataChannel("channel");
dataChannel.onopen = (e) => {
console.log("Connection opened");
};
dataChannel.onmessage = (msg) => {
console.log("Received message from peer:\n", msg.data);
mutable chatLog += `${msg.data}\n`;
};
return dataChannel;
}
Insert cell
{
setTimeout(async () => {
const offer = await localConnection.createOffer();
await localConnection.setLocalDescription(offer);
console.log("Offering connection!");
}, 1000);
}
Insert cell
Insert cell
{
if (answer) {
localConnection.setRemoteDescription(JSON.parse(answer));
console.log(localConnection);
}
}
Insert cell
{
if (chatBox) {
dataChannel.send(chatBox);
viewof chatBox.value = "";
mutable chatLog += `${chatBox}\n`;
}
}
Insert cell
JSON.parse(JSON.stringify(localConnection.localDescription))
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more