Skip to content

Commit c486ed3

Browse files
authored
temporary disable ping-pong on the device connectivity deal due to the instability of pinging in high-traffic environments (100+ omi devices)// RSSI reading. (#2952)
1 parent 6bf7dfe commit c486ed3

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

app/lib/services/devices.dart

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,42 +212,23 @@ class DeviceService implements IDeviceService {
212212
await _mutex.acquire();
213213
try {
214214
debugPrint("ensureConnection ${_connection?.device.id} ${_connection?.status} $force");
215+
215216
// Not force
216217
if (!force && _connection != null) {
217218
if (_connection?.device.id != deviceId || _connection?.status != DeviceConnectionState.connected) {
218219
return null;
219220
}
220221

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
232223
return _connection;
233224
}
234225

235226
// Force
236227
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-
247228
return _connection;
248229
}
249230

250-
// connect
231+
// Connect
251232
try {
252233
await _connectToDevice(deviceId);
253234
} on DeviceConnectionException catch (e) {

0 commit comments

Comments
 (0)