|
...
|
...
|
@@ -257,12 +257,21 @@ class WebSocketService with WidgetsBindingObserver { |
|
|
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
|
|
switch (state) {
|
|
|
|
case AppLifecycleState.resumed:
|
|
|
|
// Do not wait for a background reconnect backoff after returning to
|
|
|
|
// the foreground. A disconnected socket should be restored at once.
|
|
|
|
if (_socket == null && !_isConnecting) {
|
|
|
|
_cancelReconnect();
|
|
|
|
}
|
|
|
|
_connectIfNeeded();
|
|
|
|
return;
|
|
|
|
case AppLifecycleState.inactive:
|
|
|
|
return;
|
|
|
|
case AppLifecycleState.hidden:
|
|
|
|
case AppLifecycleState.paused:
|
|
|
|
// Keep the authenticated socket alive in the background. The OS may
|
|
|
|
// still suspend networking or reclaim the process, in which case the
|
|
|
|
// existing disconnect handler will reconnect when execution resumes.
|
|
|
|
return;
|
|
|
|
case AppLifecycleState.detached:
|
|
|
|
_cancelReconnect();
|
|
|
|
_closeSocket();
|
...
|
...
|
|