fixed problem when circuit changed, stream couldnt be started again
This commit is contained in:
parent
bb39ac743b
commit
4e5a822ba7
|
|
@ -173,7 +173,7 @@ async function addLocalDescription(peer) {
|
||||||
|
|
||||||
function signalRemotePeer(data){
|
function signalRemotePeer(data){
|
||||||
streamws.send(data);
|
streamws.send(data);
|
||||||
console.log('[NOVNC] Signaling remote peer...');
|
console.log('[NOVNC] Signaling remote peer...', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function gotRemoteStream(e){
|
function gotRemoteStream(e){
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,29 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
document.addEventListener('oncreateroom', function(){
|
document.addEventListener('oncreateroom', function(){
|
||||||
|
let ws_scheme;
|
||||||
|
//var ws_scheme = window.location.protocol == "https:" ? "wss://" : "ws://";
|
||||||
|
if (server === '127.0.0.1'){
|
||||||
|
// Local deploy
|
||||||
|
server = '127.0.0.1:8000';
|
||||||
|
ws_scheme = "ws://";
|
||||||
|
}else{
|
||||||
|
ws_scheme = "wss://";
|
||||||
|
}
|
||||||
|
|
||||||
// Creo WS de stream
|
// Creo WS de stream
|
||||||
|
console.log('STREAM WS: ', ws_scheme +
|
||||||
|
//'test.unibotics.org' +
|
||||||
|
//'127.0.0.1:8000' +
|
||||||
|
server +
|
||||||
|
'/ws/stream/' +
|
||||||
|
room_name +
|
||||||
|
'/');
|
||||||
streamws = new WebSocket(
|
streamws = new WebSocket(
|
||||||
'ws://' +
|
ws_scheme +
|
||||||
'127.0.0.1:8000' +
|
//'test.unibotics.org'+
|
||||||
|
//'127.0.0.1:8000' +
|
||||||
|
server +
|
||||||
'/ws/stream/' +
|
'/ws/stream/' +
|
||||||
room_name +
|
room_name +
|
||||||
'/'
|
'/'
|
||||||
|
|
|
||||||
15
vnc.html
15
vnc.html
|
|
@ -330,6 +330,7 @@
|
||||||
let room_name;
|
let room_name;
|
||||||
let users = false;
|
let users = false;
|
||||||
let streamws;
|
let streamws;
|
||||||
|
let server;
|
||||||
|
|
||||||
function createRoom(){
|
function createRoom(){
|
||||||
room_name = Date.now()+Math.round(Math.random()*10000);
|
room_name = Date.now()+Math.round(Math.random()*10000);
|
||||||
|
|
@ -341,8 +342,12 @@
|
||||||
var canvas = document.querySelector('#noVNC_container canvas');
|
var canvas = document.querySelector('#noVNC_container canvas');
|
||||||
// Search for canvas element
|
// Search for canvas element
|
||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
|
canvas = document.querySelector('#noVNC_container canvas');
|
||||||
if(canvas === null){
|
if(canvas === null){
|
||||||
canvas = document.querySelector('#noVNC_container canvas');
|
canvas = document.querySelector('#noVNC_container canvas');
|
||||||
|
console.log('[NOVNC] ',canvas);
|
||||||
|
stream_set = false;
|
||||||
|
users = false;
|
||||||
}else{
|
}else{
|
||||||
if(!stream_set){
|
if(!stream_set){
|
||||||
// Send message to parent
|
// Send message to parent
|
||||||
|
|
@ -355,12 +360,16 @@
|
||||||
}
|
}
|
||||||
},2000);
|
},2000);
|
||||||
|
|
||||||
|
window.addEventListener('message', function(e){
|
||||||
|
console.log('[NOVNC] mensaje: ', e.data);
|
||||||
|
let data = JSON.parse(e.data);
|
||||||
|
if(data['command'] === 'start'){
|
||||||
|
// Set server variable
|
||||||
|
server = data['server'];
|
||||||
|
|
||||||
// Creo la sala
|
// Creo la sala
|
||||||
createRoom();
|
createRoom();
|
||||||
|
|
||||||
window.addEventListener('message', function(e){
|
|
||||||
console.log('[NOVNC] mensaje: ', e.data);
|
|
||||||
if(e.data === 'start'){
|
|
||||||
console.log('Empezar el stream');
|
console.log('Empezar el stream');
|
||||||
// Send stream_room to parent
|
// Send stream_room to parent
|
||||||
parent.postMessage(JSON.stringify({'stream':room_name}),'*');
|
parent.postMessage(JSON.stringify({'stream':room_name}),'*');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue