@@ -52,12 +52,10 @@ class LiveQueryReconnectingController with WidgetsBindingObserver {
52
52
53
53
LiveQueryReconnectingController (
54
54
this ._reconnect, this ._eventStream, this .debug) {
55
- Connectivity ().onConnectivityChanged.listen ((ConnectivityResult state) {
56
- if (! _isOnline && state != ConnectivityResult .none) _retryState = 0 ;
57
- _isOnline = state != ConnectivityResult .none;
58
- if (debug) print ('$DEBUG_TAG : $state ' );
59
- _setReconnect ();
60
- });
55
+
56
+ Connectivity ().checkConnectivity ().then (_connectivityChanged);
57
+ Connectivity ().onConnectivityChanged.listen (_connectivityChanged);
58
+
61
59
_eventStream.listen ((LiveQueryClientEvent event) {
62
60
switch (event) {
63
61
case LiveQueryClientEvent .CONNECTED :
@@ -83,6 +81,13 @@ class LiveQueryReconnectingController with WidgetsBindingObserver {
83
81
WidgetsBinding .instance.addObserver (this );
84
82
}
85
83
84
+ void _connectivityChanged (ConnectivityResult state){
85
+ if (! _isOnline && state != ConnectivityResult .none) _retryState = 0 ;
86
+ _isOnline = state != ConnectivityResult .none;
87
+ if (debug) print ('$DEBUG_TAG : $state ' );
88
+ _setReconnect ();
89
+ }
90
+
86
91
@override
87
92
void didChangeAppLifecycleState (AppLifecycleState state) {
88
93
switch (state) {
@@ -102,9 +107,9 @@ class LiveQueryReconnectingController with WidgetsBindingObserver {
102
107
retryInterval[_retryState] >= 0 ) {
103
108
_currentTimer =
104
109
Timer (Duration (milliseconds: retryInterval[_retryState]), () {
105
- _currentTimer = null ;
106
- _reconnect ();
107
- });
110
+ _currentTimer = null ;
111
+ _reconnect ();
112
+ });
108
113
if (debug)
109
114
print ('$DEBUG_TAG : Retrytimer set to ${retryInterval [_retryState ]}ms' );
110
115
if (_retryState < retryInterval.length - 1 ) _retryState++ ;
@@ -123,7 +128,7 @@ class Client {
123
128
_client = client ??
124
129
ParseHTTPClient (
125
130
sendSessionId:
126
- autoSendSessionId ?? ParseCoreData ().autoSendSessionId,
131
+ autoSendSessionId ?? ParseCoreData ().autoSendSessionId,
127
132
securityContext: ParseCoreData ().securityContext);
128
133
129
134
_debug = isDebugEnabled (objectLevelDebug: debug);
@@ -137,7 +142,7 @@ class Client {
137
142
}
138
143
139
144
reconnectingController = LiveQueryReconnectingController (
140
- () => reconnect (userInitialized: false ), getClientEventStream, _debug);
145
+ () => reconnect (userInitialized: false ), getClientEventStream, _debug);
141
146
}
142
147
static Client get instance => _getInstance ();
143
148
static Client _instance;
@@ -204,7 +209,7 @@ class Client {
204
209
Future <Subscription > subscribe (QueryBuilder query) async {
205
210
if (_webSocket == null ) {
206
211
await _clientEventStream.any ((LiveQueryClientEvent event) =>
207
- event == LiveQueryClientEvent .CONNECTED );
212
+ event == LiveQueryClientEvent .CONNECTED );
208
213
}
209
214
final int requestId = _requestIdGenerator ();
210
215
final Subscription subscription = Subscription (query, requestId);
@@ -394,7 +399,7 @@ class LiveQuery {
394
399
_client = client ??
395
400
ParseHTTPClient (
396
401
sendSessionId:
397
- autoSendSessionId ?? ParseCoreData ().autoSendSessionId,
402
+ autoSendSessionId ?? ParseCoreData ().autoSendSessionId,
398
403
securityContext: ParseCoreData ().securityContext);
399
404
400
405
_debug = isDebugEnabled (objectLevelDebug: debug);
0 commit comments