added own_id param as statefull id for viewer
This commit is contained in:
parent
ec4c4dcb06
commit
5c47882b19
@ -59,9 +59,12 @@ sf.streamId_text = "Loading...";
|
||||
sf.streamURL_text = "Loading...";
|
||||
|
||||
let connectToId = new URL(window.location.href).searchParams.get("id");
|
||||
let ownId = new URL(window.location.href).searchParams.get("own_id")
|
||||
|
||||
let bitrate = new URL(window.location.href).searchParams.get("br") || 50000;
|
||||
|
||||
//Connect to ID means: Iam the screensharer now.
|
||||
//no ID Specified = Iam the Viewer
|
||||
if (connectToId) {
|
||||
sf.streamURLCont_style = "display:none";
|
||||
sf.connectToCont_style = "display:block";
|
||||
@ -71,11 +74,23 @@ if (connectToId) {
|
||||
sf.connectToCont_style = "display:none";
|
||||
}
|
||||
|
||||
var peer = new Peer({
|
||||
host: window.location.hostname,
|
||||
port: window.location.port,
|
||||
path: "/peerjs",
|
||||
});
|
||||
if (ownId) {
|
||||
var peer = new Peer(ownId, {
|
||||
host: window.location.hostname,
|
||||
port: window.location.port,
|
||||
path: "/peerjs",
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
var peer = new Peer({
|
||||
host: window.location.hostname,
|
||||
port: window.location.port,
|
||||
path: "/peerjs",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function bitrateTransform(sdp) {
|
||||
var arr = sdp.split("\r\n");
|
||||
@ -101,7 +116,8 @@ let currentStream = undefined;
|
||||
peer.on("open", (id) => {
|
||||
console.log("ID", id);
|
||||
sf.streamId_text = id;
|
||||
let url = new URL(window.location.href);
|
||||
//clearing the params from the url
|
||||
let url = new URL(window.location.href.split('?')[0]);
|
||||
url.searchParams.set("id", id);
|
||||
sf.streamURL_text = url.href;
|
||||
sf.streamURL_href = url.href;
|
||||
@ -117,7 +133,7 @@ peer.on("open", (id) => {
|
||||
video: true,
|
||||
})
|
||||
.then((stream) => {
|
||||
if(currentStream) {
|
||||
if (currentStream) {
|
||||
currentStream.getTracks().forEach(track => track.stop())
|
||||
}
|
||||
currentStream = stream;
|
||||
|
Loading…
Reference in New Issue
Block a user