diff --git a/index.html b/index.html
index 3d7b7f15..ed637b38 100644
--- a/index.html
+++ b/index.html
@@ -6,13 +6,8 @@ textarea {
height: 50px;
}
-
-
+
Browser base64 Session Description
Golang base64 Session Description:
@@ -37,6 +32,7 @@ function postSession(session) {
xhttp.open("POST", "/session", true);
xhttp.setRequestHeader("Content-type", "text/plain");
xhttp.send(session);
+
}
let pc = new RTCPeerConnection({
@@ -50,6 +46,11 @@ let log = msg => {
document.getElementById('div').innerHTML += msg + '
'
}
+let inputChannel = pc.createDataChannel('foo')
+inputChannel.onclose = () => console.log('inputChannel has closed')
+inputChannel.onopen = () => console.log('inputChannel has opened')
+inputChannel.onmessage = e => log(`Message from DataChannel '${inputChannel.label}' payload '${e.data}'`)
+
pc.ontrack = function (event) {
var el = document.createElement(event.track.kind)
el.srcObject = event.streams[0]
@@ -70,6 +71,14 @@ pc.onicecandidate = event => {
pc.createOffer({offerToReceiveVideo: true, offerToReceiveAudio: true}).then(d => pc.setLocalDescription(d)).catch(log)
+document.body.onkeydown = function(e){
+ inputChannel.send(e.keyCode)
+};
+
+document.body.onkeyup = function(e){
+ inputChannel.send(-e.keyCode)
+};
+
window.startSession = () => {
let sd = document.getElementById('remoteSessionDescription').value
if (sd === '') {
@@ -84,4 +93,4 @@ window.startSession = () => {
}
-