@apocaliss92/scrypted-reolink-native 0.5.28 → 0.5.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.nodejs.js +1 -1
- package/dist/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/baichuan-base.ts +22 -11
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/baichuan-base.ts
CHANGED
|
@@ -486,19 +486,30 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
|
|
|
486
486
|
this.lastDisconnectTime = now;
|
|
487
487
|
|
|
488
488
|
logger.log(
|
|
489
|
-
`Socket closed
|
|
489
|
+
`Socket closed${timeSinceLastDisconnect != null ? ` (last disconnect ${timeSinceLastDisconnect}ms ago)` : " (first disconnect)"} — api object kept alive, will reconnect on next use`,
|
|
490
490
|
);
|
|
491
491
|
|
|
492
|
-
//
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
492
|
+
// The api object itself stays alive across socket disconnects:
|
|
493
|
+
// - It's NOT explicitly closed (no `_closed = true`), so simple
|
|
494
|
+
// event listeners, the email-push auto-bridge (when used),
|
|
495
|
+
// recordings cache, sleep inference state, etc. are preserved
|
|
496
|
+
// for the next reconnect cycle.
|
|
497
|
+
// - The next `ensureBaichuanClient` call sees `api.isReady=false`
|
|
498
|
+
// AND `api.isClosed=false` and routes through
|
|
499
|
+
// `api.ensureConnected()`, which reuses the same api with a
|
|
500
|
+
// freshly reconnected socket pool — see the
|
|
501
|
+
// `socket disconnected but API still valid` branch above.
|
|
502
|
+
// - If the lib reconnect fails repeatedly, the same caller
|
|
503
|
+
// falls back to `cleanupBaichuanApi()` + full recreate (the
|
|
504
|
+
// catch around `ensureConnected()` in ensureBaichuanClient).
|
|
505
|
+
//
|
|
506
|
+
// Calling `cleanupBaichuanApi()` here would defeat all of that:
|
|
507
|
+
// it sets `_closed=true` (next ensureBaichuanClient destroys +
|
|
508
|
+
// recreates from scratch), and worse it tears down any consumer
|
|
509
|
+
// registered against `api.simpleEventListeners` — like the lib
|
|
510
|
+
// email-push auto-bridge — for the entire gap until the next
|
|
511
|
+
// `ensureBaichuanClient` call (which on battery cams can be
|
|
512
|
+
// minutes). We deliberately don't.
|
|
502
513
|
|
|
503
514
|
// Call custom close handler if provided
|
|
504
515
|
if (callbacks.onClose) {
|