fix: 修复销毁websocket后还有心跳检测的问题
This commit is contained in:
parent
8720c43570
commit
86c87b2cc4
@ -388,6 +388,7 @@ const initHandler = () => {
|
|||||||
if (!appStore.hasToken) return;
|
if (!appStore.hasToken) return;
|
||||||
loadRecentConversation();
|
loadRecentConversation();
|
||||||
///loadConversationMsgList();
|
///loadConversationMsgList();
|
||||||
|
initTypewriterManager();
|
||||||
initWebSocket();
|
initWebSocket();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -395,8 +396,6 @@ onMounted(() => {
|
|||||||
try {
|
try {
|
||||||
getMainPageData();
|
getMainPageData();
|
||||||
addNoticeListener();
|
addNoticeListener();
|
||||||
initTypewriterManager();
|
|
||||||
|
|
||||||
// 有token时,加载最近会话、最近消息、初始化socket
|
// 有token时,加载最近会话、最近消息、初始化socket
|
||||||
initHandler();
|
initHandler();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -121,8 +121,7 @@ export class WebSocketManager {
|
|||||||
this.connectionState = false;
|
this.connectionState = false;
|
||||||
this._safeCallCallback("onError", {
|
this._safeCallCallback("onError", {
|
||||||
type: "CONNECTION_ERROR",
|
type: "CONNECTION_ERROR",
|
||||||
message:
|
message: "uni.connectSocket返回的SocketTask对象无效",
|
||||||
"uni.connectSocket返回的SocketTask对象无效",
|
|
||||||
originalError: null,
|
originalError: null,
|
||||||
});
|
});
|
||||||
this.scheduleReconnect();
|
this.scheduleReconnect();
|
||||||
@ -427,9 +426,7 @@ export class WebSocketManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
||||||
console.error(
|
console.error(`达到最大重连次数(${this.maxReconnectAttempts}),停止重连`);
|
||||||
`达到最大重连次数(${this.maxReconnectAttempts}),停止重连`
|
|
||||||
);
|
|
||||||
this.connectionState = false;
|
this.connectionState = false;
|
||||||
this.isConnecting = false;
|
this.isConnecting = false;
|
||||||
|
|
||||||
@ -573,6 +570,7 @@ export class WebSocketManager {
|
|||||||
*/
|
*/
|
||||||
close() {
|
close() {
|
||||||
this.stopHeartbeat();
|
this.stopHeartbeat();
|
||||||
|
this.resetConnectionState();
|
||||||
|
|
||||||
// 清理重连定时器
|
// 清理重连定时器
|
||||||
TimerUtils.clearTimer(this.reconnectTimer);
|
TimerUtils.clearTimer(this.reconnectTimer);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user