<div><video id="stream" autoplay playsinline>Your browser doesn't support video</video></div>
<div>Status: <span id="status">unknown</span></div>
<div><textarea id="text" cols=40 rows=4></textarea></div>
+ <br/>
+ <div>
+ <label for="peer-connect">Enter peer id</label>
+ <input id="peer-connect" type="text" name="text">
+ <button onclick="onConnectClicked();">Connect</button>
+ </div>
+
<div>Our id is <b id="peer-id">unknown</b></div>
<br/>
<div>
// Promise for local stream after constraints are approved by the user
var local_stream_promise;
+function onConnectClicked() {
+ var id = document.getElementById("peer-connect").value;
+ if (id == "") {
+ alert("Peer id must be filled out");
+ return;
+ }
+
+ ws_conn.send("SESSION " + id);
+}
+
function getOurId() {
return Math.floor(Math.random() * (9000 - 10) + 10).toString();
}
case "HELLO":
setStatus("Registered with server, waiting for call");
return;
+ case "SESSION_OK":
+ setStatus("Starting negotiation");
+ if (!peer_connection)
+ createCall(null).then (generateOffer);
+ return;
default:
if (event.data.startsWith("ERROR")) {
handleIncomingError(event.data);