From: Ruben Beltran del Rio Date: Sun, 27 Sep 2020 20:36:52 +0000 (+0200) Subject: Fix rooms and force ws protocol X-Git-Url: https://git.r.bdr.sh/rbdr/junction/commitdiff_plain/02071d8e6e45dd253298d2e450ecfffacccaec19?hp=93fe1aee43a79a23d4c418c230fde0e451259279 Fix rooms and force ws protocol --- diff --git a/extension/content_script.js b/extension/content_script.js index 741e1c4..84a2fd3 100644 --- a/extension/content_script.js +++ b/extension/content_script.js @@ -4,7 +4,7 @@ const internals = { - kSocketUrl: 'http://unlimited.pizza:8000/', + kSocketUrl: 'https://junction.unlimited.pizza/', port: null, socket: null, @@ -19,14 +19,25 @@ try { const mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true }); - internals.socket = io(internals.kSocketUrl); + internals.socket = io(internals.kSocketUrl, { + transports: ['websocket'] + }); + + internals.socket.on('error', function(error) { + + console.error('GENERAL ERROR', error); + }); + + internals.socket.on('connect_error', function(error) { + + console.error('CONNNECT ERROR', error); + }); - console.log('Connecting to server'); internals.socket.on('connect', function() { - console.log("Connected to signaling server"); + console.log("Connected to signaling server, group: ", data.currentUrl); internals.socket.emit('join', { - 'url': currentUrl, + 'url': data.currentUrl, }); }); @@ -48,7 +59,6 @@ console.log(`There are now ${internals.peers} participants`); }); - console.log('Done!'); internals.createAudioElement(data.tada); } catch (err) { diff --git a/extension/junction.js b/extension/junction.js index f3e1fb4..2c32053 100644 --- a/extension/junction.js +++ b/extension/junction.js @@ -2,6 +2,7 @@ const internals = { promisesSupported: !!(window.browser), port: null, + currentUrl: null, icons: { call: { @@ -31,6 +32,7 @@ const internals = { port.postMessage({ action: 'joinAudioCall', data: { + currentUrl: internals.currentUrl, tada: internals.getRoot().runtime.getURL('sounds/tada.wav') } }); @@ -48,6 +50,7 @@ const internals = { onDisconnect() { internals.getRoot().browserAction.setBadgeText({ text: '' }, () => {}); internals.setIcon('call'); + internals.currentUrl = null; internals.port = null; internals.getRoot().browserAction.enable(); }, @@ -57,13 +60,19 @@ const internals = { internals.getRoot().browserAction.disable(); const activeTabs = await internals.getActiveTabs(); - const execution = await internals.getRoot().tabs.executeScript(activeTabs[0].id, { - file: '/build/content_script.js' - }); + internals.currentUrl = activeTabs[0].url; + const execution = await internals.getRoot().tabs.executeScript(activeTabs[0].id, { + file: '/build/content_script.js' + }, () => { - if (!execution || !execution[0]) { + if (internals.getRoot().runtime.lastError) { internals.onDisconnect(); } + }); + + if (execution && !execution[0]) { + internals.onDisconnect(); + } } ,