提交websocket
This commit is contained in:
@@ -19,7 +19,7 @@ class webSocketUtils {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('catch');
|
console.log('catch');
|
||||||
// this.reconnect();
|
this.reconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 进入这个页面的时候创建websocket连接【整个页面随时使用】
|
// 进入这个页面的时候创建websocket连接【整个页面随时使用】
|
||||||
@@ -48,7 +48,7 @@ class webSocketUtils {
|
|||||||
clearInterval(this.heartbeatInterval);
|
clearInterval(this.heartbeatInterval);
|
||||||
this.is_open_socket = true;
|
this.is_open_socket = true;
|
||||||
this.canReconnect = true;
|
this.canReconnect = true;
|
||||||
// this.start();
|
this.start();
|
||||||
// 注:只有连接正常打开中 ,才能正常收到消息
|
// 注:只有连接正常打开中 ,才能正常收到消息
|
||||||
this.socketTask.onMessage((e) => {
|
this.socketTask.onMessage((e) => {
|
||||||
// 字符串转json
|
// 字符串转json
|
||||||
@@ -71,7 +71,7 @@ class webSocketUtils {
|
|||||||
title: `网络连接失败,正尝试第${this.connectNum}次连接`,
|
title: `网络连接失败,正尝试第${this.connectNum}次连接`,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
});
|
});
|
||||||
// this.reconnect();
|
this.reconnect();
|
||||||
this.connectNum += 1;
|
this.connectNum += 1;
|
||||||
} else {
|
} else {
|
||||||
// uni.$emit('connectError');
|
// uni.$emit('connectError');
|
||||||
@@ -91,7 +91,7 @@ class webSocketUtils {
|
|||||||
|
|
||||||
this.is_open_socket = false;
|
this.is_open_socket = false;
|
||||||
if (this.canReconnect) {
|
if (this.canReconnect) {
|
||||||
// this.reconnect();
|
this.reconnect();
|
||||||
this.canReconnect = false;
|
this.canReconnect = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user