feat: sockt 弹窗功能添加
This commit is contained in:
@@ -187,6 +187,46 @@ class SocketService {
|
||||
return this.socket?.id || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动重连
|
||||
* @returns {boolean} 是否触发重连
|
||||
*/
|
||||
reconnect() {
|
||||
if (!this.socket) {
|
||||
logger.warn('socketService', 'Cannot reconnect: socket not initialized');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.connected) {
|
||||
logger.info('socketService', 'Already connected, no need to reconnect');
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.info('socketService', 'Manually triggering reconnection...');
|
||||
|
||||
// 重置重连计数
|
||||
this.reconnectAttempts = 0;
|
||||
|
||||
// 触发重连
|
||||
this.socket.connect();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前重连尝试次数
|
||||
*/
|
||||
getReconnectAttempts() {
|
||||
return this.reconnectAttempts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最大重连次数
|
||||
*/
|
||||
getMaxReconnectAttempts() {
|
||||
return this.maxReconnectAttempts;
|
||||
}
|
||||
|
||||
// ==================== 事件推送专用方法 ====================
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user