fix(core): Fix reconnections not working properly
This commit is contained in:
parent
70d4d6c56f
commit
4321573dfb
@ -374,8 +374,11 @@ class XmppConnection {
|
|||||||
|
|
||||||
// Connect again
|
// Connect again
|
||||||
// ignore: cascade_invocations
|
// ignore: cascade_invocations
|
||||||
_log.finest('Calling connect() from _attemptReconnection');
|
_log.finest('Calling _connectImpl() from _attemptReconnection');
|
||||||
await connect(waitForConnection: true);
|
await _connectImpl(
|
||||||
|
waitForConnection: true,
|
||||||
|
ignoreLock: true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when a stream ending error has occurred
|
/// Called when a stream ending error has occurred
|
||||||
@ -1133,13 +1136,21 @@ class XmppConnection {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The private implementation for [XmppConnection.connect]. The parameters have
|
||||||
|
/// the same meaning as with [XmppConnection.connect].
|
||||||
|
///
|
||||||
|
/// [ignoreLock] is a flag that, if true, causes the method to not try to aquire
|
||||||
|
/// a connection lock. This is useful when we already aquired the connection lock,
|
||||||
|
/// for example, in _attemptReconnection.
|
||||||
Future<Result<bool, XmppError>> _connectImpl({
|
Future<Result<bool, XmppError>> _connectImpl({
|
||||||
String? lastResource,
|
String? lastResource,
|
||||||
bool waitForConnection = false,
|
bool waitForConnection = false,
|
||||||
bool shouldReconnect = true,
|
bool shouldReconnect = true,
|
||||||
bool waitUntilLogin = false,
|
bool waitUntilLogin = false,
|
||||||
bool enableReconnectOnSuccess = true,
|
bool enableReconnectOnSuccess = true,
|
||||||
|
bool ignoreLock = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (!ignoreLock) {
|
||||||
if (await _testAndSetIsConnectionRunning()) {
|
if (await _testAndSetIsConnectionRunning()) {
|
||||||
_log.fine(
|
_log.fine(
|
||||||
'Cancelling this connection attempt as one appears to be already running.',
|
'Cancelling this connection attempt as one appears to be already running.',
|
||||||
@ -1152,6 +1163,9 @@ class XmppConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await _resetIsConnectionRunning();
|
await _resetIsConnectionRunning();
|
||||||
|
} else {
|
||||||
|
_log.fine('Ignoring connection lock as ignoreLock = true');
|
||||||
|
}
|
||||||
|
|
||||||
if (waitUntilLogin) {
|
if (waitUntilLogin) {
|
||||||
_log.finest('Setting up completer for awaiting completed login');
|
_log.finest('Setting up completer for awaiting completed login');
|
||||||
|
Loading…
Reference in New Issue
Block a user