@apocaliss92/scrypted-reolink-native 0.3.15 → 0.3.17

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/plugin.zip CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apocaliss92/scrypted-reolink-native",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "Use any reolink camera with Scrypted, even older/unsupported models without HTTP protocol support",
5
5
  "author": "@apocaliss92",
6
6
  "license": "Apache",
@@ -307,7 +307,7 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
307
307
 
308
308
  // Start ping and auto-renewal for TCP connections
309
309
  if (this.transport === 'tcp') {
310
- this.startConnectionMaintenance(api);
310
+ // this.startConnectionMaintenance(api);
311
311
  }
312
312
 
313
313
  // Start event check for all connections
@@ -823,6 +823,31 @@ export abstract class BaseBaichuanClass extends ScryptedDeviceBase {
823
823
  return api;
824
824
  }
825
825
 
826
+ /**
827
+ * Teardown a single stream client by streamKey.
828
+ *
829
+ * This is useful for non-stream features (e.g. intercom) that still use createStreamClient()
830
+ * and need to ensure the underlying Baichuan session is torn down at the end of the operation.
831
+ */
832
+ async teardownStreamClient(streamKey: string, options?: { timeoutMs?: number }): Promise<void> {
833
+ const api = this.streamClients.get(streamKey);
834
+ // Remove first to avoid re-use while closing (and to ensure teardown even if close hangs).
835
+ this.streamClients.delete(streamKey);
836
+ if (!api) return;
837
+
838
+ const timeoutMs = options?.timeoutMs ?? 2000;
839
+ const sleepMs = async (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));
840
+
841
+ try {
842
+ await Promise.race([
843
+ api.close({ reason: `teardownStreamClient:${streamKey}` }),
844
+ sleepMs(timeoutMs),
845
+ ]);
846
+ } catch {
847
+ // ignore
848
+ }
849
+ }
850
+
826
851
  /**
827
852
  * Cleanup all stream clients (called during device cleanup)
828
853
  */