]> git.r.bdr.sh - rbdr/junction/commitdiff
Fix rooms and force ws protocol
authorRuben Beltran del Rio <redacted>
Sun, 27 Sep 2020 20:36:52 +0000 (22:36 +0200)
committerRuben Beltran del Rio <redacted>
Sun, 27 Sep 2020 20:36:52 +0000 (22:36 +0200)
extension/content_script.js
extension/junction.js

index 741e1c4a88df1b03e1ca4c348d910adc866b193e..84a2fd3bce3ed6bd3cd1a306e860fa9f5eed43df 100644 (file)
@@ -4,7 +4,7 @@
 
   const internals = {
 
-    kSocketUrl: 'http://unlimited.pizza:8000/',
+    kSocketUrl: 'https://junction.unlimited.pizza/',
 
     port: null,
     socket: null,
       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) {
index f3e1fb49c6b493baa66b5a9fe25a1993b1082662..2c32053918aec6d2060164356f84e277f37c5dfb 100644 (file)
@@ -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();
+    }
   }
   ,