Browse Source

bugfix:处理不能触屏问题

leo 1 year ago
parent
commit
3e4f6d887a
3 changed files with 41 additions and 26 deletions
  1. 18 12
      static/webRtcYJ/WXdraw.js
  2. 10 6
      static/webRtcYJ/WXtrialInterface.html
  3. 13 8
      static/webRtcYJ/websocket.js

+ 18 - 12
static/webRtcYJ/WXdraw.js

@@ -48,7 +48,6 @@ function throttle(fn, delay) {
 const throttleDoConnectDirectives = throttle(() => {
 const throttleDoConnectDirectives = throttle(() => {
   doConnectDirectives();
   doConnectDirectives();
 }, 100);
 }, 100);
-
 function doConnectDirectives() {
 function doConnectDirectives() {
   videoWidth = Number(resolvingPower) ? Number(resolvingPower) : 720;
   videoWidth = Number(resolvingPower) ? Number(resolvingPower) : 720;
   videoHeight = videoWidth === 720 ? 1280 : 1920;
   videoHeight = videoWidth === 720 ? 1280 : 1920;
@@ -88,25 +87,32 @@ function doConnectDirectives() {
   };
   };
   wsss.onerror = function (e) {
   wsss.onerror = function (e) {
     // console.log('🚀 ~ file: WXdraw.js ~ line 82 ~ onerror ~ e', e);
     // console.log('🚀 ~ file: WXdraw.js ~ line 82 ~ onerror ~ e', e);
-    wsss.close(1006);
+    // wsss.close(1006);
     // throttle(doConnectDirectives, 100);
     // throttle(doConnectDirectives, 100);
     // if (errorTime > 1000) {
     // if (errorTime > 1000) {
     //   quit();
     //   quit();
     // }
     // }
+    // 异常关闭,重连
+    throttleDoConnectDirectives();
+    // doConnectDirectives();
+    // throttle(doConnectDirectives, 100);
+    if (errorTime > 1000) {
+      quit();
+    }
   };
   };
   wsss.onclose = function (e) {
   wsss.onclose = function (e) {
     // console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e);
     // console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e);
     // new WebSocket(e.)
     // new WebSocket(e.)
     // doConnectDirectives();
     // doConnectDirectives();
-    if (e.code === 1006) {
-      // 异常关闭,重连
-      throttleDoConnectDirectives();
-      // doConnectDirectives();
-      // throttle(doConnectDirectives, 100);
-      if (errorTime > 1000) {
-        quit();
-      }
-    }
+    // if (e.code === 1006) {
+    //   // 异常关闭,重连
+    //   throttleDoConnectDirectives();
+    //   // doConnectDirectives();
+    //   // throttle(doConnectDirectives, 100);
+    //   if (errorTime > 1000) {
+    //     quit();
+    //   }
+    // }
   };
   };
   wsss.onmessage = function (res) {
   wsss.onmessage = function (res) {
     var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
     var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
@@ -283,7 +289,7 @@ function doConnectDirectives() {
         (window.currentPhoneSize.width !==
         (window.currentPhoneSize.width !==
           Math.min(result.data.width, result.data.height) ||
           Math.min(result.data.width, result.data.height) ||
           window.currentPhoneSize.height !==
           window.currentPhoneSize.height !==
-            Math.max(result.data.width, result.data.height) ||
+          Math.max(result.data.width, result.data.height) ||
           window.currentPhoneSize.dpi !== result.data.dpi)
           window.currentPhoneSize.dpi !== result.data.dpi)
       ) {
       ) {
         // 获取到的分辨率与当前分辨率不符
         // 获取到的分辨率与当前分辨率不符

+ 10 - 6
static/webRtcYJ/WXtrialInterface.html

@@ -443,15 +443,18 @@
       let engine = null;
       let engine = null;
       let connectData = null;
       let connectData = null;
       let debounceSwitchingScreens = debounce(
       let debounceSwitchingScreens = debounce(
-        function () {
+        function (bool) {
           $('#playVideo').hide();
           $('#playVideo').hide();
           $('#playCanvas').show();
           $('#playCanvas').show();
           $('.weui-mask_transparent').show();
           $('.weui-mask_transparent').show();
           $('.weui-toast').show();
           $('.weui-toast').show();
-          engine.disconnect();
+          if(bool) {
+            engine.disconnect();
+          } 
+        
           wsss.close();
           wsss.close();
-          decodeWoker.postMessage('close');
-          decodeWoker.terminate();
+          // decodeWoker.postMessage('close');
+          // decodeWoker.terminate();
           webSocketWorker.postMessage('close');
           webSocketWorker.postMessage('close');
           connect();
           connect();
         },
         },
@@ -460,10 +463,11 @@
       );
       );
       window.addEventListener('message', function (e) {
       window.addEventListener('message', function (e) {
         let data = e.data;
         let data = e.data;
-        if (data.bool && isVideo && !$('#playCanvas').is(':visible') && !isShowiPhoneWebRTC) {
+        let bool = data.bool && isVideo && !$('#playCanvas').is(':visible') && !isShowiPhoneWebRTC
+        if (bool) {
           document.getElementById('playVideo').play();
           document.getElementById('playVideo').play();
-          debounceSwitchingScreens();
         }
         }
+        debounceSwitchingScreens(bool);
       });
       });
       // 开发环境
       // 开发环境
       var isDev =
       var isDev =

+ 13 - 8
static/webRtcYJ/websocket.js

@@ -31,16 +31,21 @@ function doConnect() {
     }
     }
   }, 3000);
   }, 3000);
   ws.onerror = function () {
   ws.onerror = function () {
-    ws.close(1006);
+    // ws.close(1006);
+    clearInterval(intervaler);
+    throttle(doConnect, 100);
+    if (errorTime > 1000) {
+      self.postMessage('close');
+    }
   };
   };
   ws.addEventListener('close', function (e) {
   ws.addEventListener('close', function (e) {
-    if (e.code === 1006) {
-      clearInterval(intervaler);
-      throttle(doConnect, 100);
-      if (errorTime > 1000) {
-        self.postMessage('close');
-      }
-    }
+    // if (e.code === 1006) {
+    //   clearInterval(intervaler);
+    //   throttle(doConnect, 100);
+    //   if (errorTime > 1000) {
+    //     self.postMessage('close');
+    //   }
+    // }
   });
   });
 
 
   ws.addEventListener('open', function (event) {
   ws.addEventListener('open', function (event) {