feat(core): Use _testAndSetIsConnectionRunning
This commit is contained in:
parent
e1e492832e
commit
70d4d6c56f
@ -1140,7 +1140,17 @@ class XmppConnection {
|
|||||||
bool waitUntilLogin = false,
|
bool waitUntilLogin = false,
|
||||||
bool enableReconnectOnSuccess = true,
|
bool enableReconnectOnSuccess = true,
|
||||||
}) async {
|
}) async {
|
||||||
_runPreConnectionAssertions();
|
if (await _testAndSetIsConnectionRunning()) {
|
||||||
|
_log.fine(
|
||||||
|
'Cancelling this connection attempt as one appears to be already running.',
|
||||||
|
);
|
||||||
|
return Future.value(
|
||||||
|
Result(
|
||||||
|
ConnectionAlreadyRunningError(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await _resetIsConnectionRunning();
|
await _resetIsConnectionRunning();
|
||||||
|
|
||||||
if (waitUntilLogin) {
|
if (waitUntilLogin) {
|
||||||
@ -1230,17 +1240,7 @@ class XmppConnection {
|
|||||||
bool waitUntilLogin = false,
|
bool waitUntilLogin = false,
|
||||||
bool enableReconnectOnSuccess = true,
|
bool enableReconnectOnSuccess = true,
|
||||||
}) async {
|
}) async {
|
||||||
if (_connectionState != XmppConnectionState.notConnected &&
|
_runPreConnectionAssertions();
|
||||||
_connectionState != XmppConnectionState.error) {
|
|
||||||
_log.fine(
|
|
||||||
'Cancelling this connection attempt as one appears to be already running.',
|
|
||||||
);
|
|
||||||
return Future.value(
|
|
||||||
Result(
|
|
||||||
ConnectionAlreadyRunningError(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final result = _connectImpl(
|
final result = _connectImpl(
|
||||||
lastResource: lastResource,
|
lastResource: lastResource,
|
||||||
|
Loading…
Reference in New Issue
Block a user