From a5e2a9cd6c9613faca8d506c96c4a01d3e77ec10 Mon Sep 17 00:00:00 2001 From: duan <1004387497@qq.com> Date: Fri, 31 May 2024 09:24:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/websocket.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/js/websocket.js b/common/js/websocket.js index 0ddd9d7..e96b30b 100644 --- a/common/js/websocket.js +++ b/common/js/websocket.js @@ -19,7 +19,7 @@ class webSocketUtils { }); } catch (e) { console.log('catch'); - // this.reconnect(); + this.reconnect(); } } // 进入这个页面的时候创建websocket连接【整个页面随时使用】 @@ -48,7 +48,7 @@ class webSocketUtils { clearInterval(this.heartbeatInterval); this.is_open_socket = true; this.canReconnect = true; - // this.start(); + this.start(); // 注:只有连接正常打开中 ,才能正常收到消息 this.socketTask.onMessage((e) => { // 字符串转json @@ -71,7 +71,7 @@ class webSocketUtils { title: `网络连接失败,正尝试第${this.connectNum}次连接`, icon: 'none', }); - // this.reconnect(); + this.reconnect(); this.connectNum += 1; } else { // uni.$emit('connectError'); @@ -91,7 +91,7 @@ class webSocketUtils { this.is_open_socket = false; if (this.canReconnect) { - // this.reconnect(); + this.reconnect(); this.canReconnect = false; } });