Explorar el Código

活检websocket:补充日志;重连

Michael Wang hace 5 años
padre
commit
74951c6a61
Se han modificado 1 ficheros con 15 adiciones y 2 borrados
  1. 15 2
      src/features/OnlineExam/Examing/FaceId.vue

+ 15 - 2
src/features/OnlineExam/Examing/FaceId.vue

@@ -212,12 +212,23 @@ export default {
           clearInterval(this.timeCountInterval);
           this.$emit("closeFaceId");
           this.closeWS();
+
+          window._hmt.push([
+            "_trackEvent",
+            "活体检测弹出框",
+            "websocket得到消息",
+          ]);
         }
       };
 
       // 重复关闭不会报错
       this.ws.onclose = function() {
         console.log("websocket连接已关闭...");
+        window._hmt.push([
+          "_trackEvent",
+          "活体检测弹出框",
+          "websocket连接关闭",
+        ]);
       };
       this.ws.onerror = () => {
         window._hmt.push([
@@ -225,12 +236,14 @@ export default {
           "活体检测弹出框",
           "websocket连接失败",
         ]);
-        if (!this.haveReceivedMsg) {
+        this.wsReconnectCount = this.wsReconnectCount || 0;
+        this.wsReconnectCount++;
+        if (!this.haveReceivedMsg && this.wsReconnectCount < 10) {
           this.ws = new WebSocket(VUE_APP_WK_SERVER_SOCKET + this.examRecordId);
           window._hmt.push([
             "_trackEvent",
             "活体检测弹出框",
-            "websocket重新连接",
+            "websocket重新连接" + this.wsReconnectCount,
           ]);
         }
         // this.showRedo("websocket连接异常,请手动点击重试");