JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://webrtc.googlecode.com/svn/trunk/samples/js/base/adapter.js"></script>
JavaScript
window.addEventListener('error', function (e) {
alert(e.message);
}, false);
var peerConnection = new RTCPeerConnection(null, {
optional: [{
RtpDataChannels: true
}]
});
peerConnection.ondatachannel = function (event) {
receiveChannel = event.channel;
receiveChannel.onmessage = function (event) {
alert(event.data);
};
};
var dataChannel = peerConnection.createDataChannel("data", {
reliable: false
});
dataChannel.send("Hello");