优化 断线 逻辑
This commit is contained in:
parent
a2b0576594
commit
8378e4331e
@ -30,16 +30,18 @@ class WKWebConnectionManager {
|
||||
static final WKWebConnectionManager _instance =
|
||||
WKWebConnectionManager._privateConstructor();
|
||||
static WKWebConnectionManager get shared => _instance;
|
||||
|
||||
bool _isLogout = false;
|
||||
bool isReconnection = false;
|
||||
final int reconnMilliseconds = 1500;
|
||||
Timer? heartTimer;
|
||||
Timer? checkNetworkTimer;
|
||||
final heartIntervalSecond = const Duration(seconds: 60);
|
||||
final heartIntervalSecond = const Duration(seconds: 30);
|
||||
final checkNetworkSecond = const Duration(seconds: 1);
|
||||
final LinkedHashMap<int, SendingMsg> _sendingMsgMap = LinkedHashMap();
|
||||
HashMap<String, Function(int, int?, ConnectionInfo?)>? _connectionListenerMap;
|
||||
MyWkSocketBase? _socket;
|
||||
|
||||
addOnConnectionStatus(String key, Function(int, int?, ConnectionInfo?) back) {
|
||||
_connectionListenerMap ??= HashMap();
|
||||
_connectionListenerMap![key] = back;
|
||||
@ -93,6 +95,9 @@ class WKWebConnectionManager {
|
||||
WKIM.shared.options.uid = '';
|
||||
WKIM.shared.options.token = '';
|
||||
WKIM.shared.messageManager.updateSendingMsgFail();
|
||||
|
||||
/// 需要清理掉 _sendingMsgMap
|
||||
_sendingMsgMap.clear();
|
||||
WKDBHelper.shared.close();
|
||||
}
|
||||
_closeAll();
|
||||
@ -236,9 +241,6 @@ class WKWebConnectionManager {
|
||||
setConnectionStatus(WKConnectStatus.success,
|
||||
reasoncode: connackPacket.reasonCode,
|
||||
info: ConnectionInfo(connackPacket.nodeId));
|
||||
// Future.delayed(Duration(seconds: 1), () {
|
||||
|
||||
// });
|
||||
try {
|
||||
WKIM.shared.conversationManager.setSyncConversation(() {
|
||||
setConnectionStatus(WKConnectStatus.syncCompleted);
|
||||
|
@ -53,6 +53,7 @@ class MyWKSocket implements MyWkSocketBase {
|
||||
try {
|
||||
if (_socket != null) {
|
||||
_socket?.add(data); // 使用安全调用操作符
|
||||
return _socket?.flush();
|
||||
}
|
||||
} catch (e) {
|
||||
Logs.debug('发送消息错误$e');
|
||||
|
Loading…
x
Reference in New Issue
Block a user