const pc = new RTCPeerConnection();
const dc = pc.createDataChannel("my channel", {
protocol: "json",
});
function handleChannelMessage(dataChannel, msg) {
switch (dataChannel.protocol) {
case "json":
/* process JSON data */
break;
case "raw":
/* process raw binary data */
break;
}
}RTCDataChannel: protocol property / notebook
RTCDataChannel: protocol property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.