Commit 85aeda42 authored by Seungha Yang's avatar Seungha Yang 🐑

sendrecv/js: Add an UI for connecting to specified peer id

Part-of: <!28>
parent 9e83c09b
Pipeline #240361 waiting for manual action with stages
in 26 seconds
......@@ -26,6 +26,13 @@
<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>
......
......@@ -25,6 +25,16 @@ var ws_conn;
// 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();
}
......@@ -115,6 +125,11 @@ function onServerMessage(event) {
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment