提交websocket

This commit is contained in:
duan
2024-05-31 09:24:45 +08:00
parent 9ac0246e02
commit a5e2a9cd6c

View File

@@ -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;
}
});