File tree Expand file tree Collapse file tree 1 file changed +3
-22
lines changed Expand file tree Collapse file tree 1 file changed +3
-22
lines changed Original file line number Diff line number Diff line change @@ -212,42 +212,23 @@ class DeviceService implements IDeviceService {
212
212
await _mutex.acquire ();
213
213
try {
214
214
debugPrint ("ensureConnection ${_connection ?.device .id } ${_connection ?.status } $force " );
215
+
215
216
// Not force
216
217
if (! force && _connection != null ) {
217
218
if (_connection? .device.id != deviceId || _connection? .status != DeviceConnectionState .connected) {
218
219
return null ;
219
220
}
220
221
221
- // connected
222
- var pongAt = _connection? .pongAt;
223
- var shouldPing = (pongAt == null || pongAt.isBefore (DateTime .now ().subtract (const Duration (seconds: 30 ))));
224
- if (shouldPing) {
225
- var ok = await _connection? .ping () ?? false ;
226
- if (! ok) {
227
- await _connection? .disconnect ();
228
- return null ;
229
- }
230
- }
231
-
222
+ // Connected
232
223
return _connection;
233
224
}
234
225
235
226
// Force
236
227
if (deviceId == _connection? .device.id && _connection? .status == DeviceConnectionState .connected) {
237
- var pongAt = _connection? .pongAt;
238
- var shouldPing = (pongAt == null || pongAt.isBefore (DateTime .now ().subtract (const Duration (seconds: 30 ))));
239
- if (shouldPing) {
240
- var ok = await _connection? .ping () ?? false ;
241
- if (! ok) {
242
- await _connection? .disconnect ();
243
- return null ;
244
- }
245
- }
246
-
247
228
return _connection;
248
229
}
249
230
250
- // connect
231
+ // Connect
251
232
try {
252
233
await _connectToDevice (deviceId);
253
234
} on DeviceConnectionException catch (e) {
You can’t perform that action at this time.
0 commit comments