disconnect method
void
disconnect()
关闭socket连接,在停止使用时,需调用该方法。
Implementation
void disconnect() {
// _networkMonitor.stopNetworkMonitoring();
_stopTimer();
if (_websocket != null) {
_websocket?.sink.close();
_websocket = null;
}
isConnected = false;
_isConnecting = false;
_pendingPayloads.clear();
msgList.clear();
payloadId = Int64.ZERO;
sendingMsg = null;
print("ChatLib: 已断开并清理资源");
}