/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { ReadResult } from "#action/response/ReadResult.js"; import { SubscriptionId } from "#interaction/Subscription.js"; import { PeerAddress } from "#peer/PeerAddress.js"; import type { SecureSession } from "#session/SecureSession.js"; import { Environment, Environmental, Lifetime, Observable } from "@matter/general"; import { ClientSubscription } from "./ClientSubscription.js"; import type { PeerSubscription } from "./PeerSubscription.js"; /** * A managed set of {@link ActiveSubscription} instances. */ export declare class ClientSubscriptions implements Lifetime.Owner { #private; constructor(lifetime: Lifetime.Owner); static [Environmental.create](env: Environment): ClientSubscriptions; join(...name: unknown[]): Lifetime; /** * Whether new data report processing is blocked. */ get isBlocked(): boolean; /** * Abort signal that fires when {@link blockNewActivity} is called. Pass to exchange read operations so in-flight * data report reads terminate promptly instead of waiting for the full report to complete. */ get readingAbortSignal(): AbortSignal; /** * Block new data report processing, abort in-flight reads, and await their completion. * * The block flag and abort signal fire synchronously so callers in sync contexts (e.g. abort handlers) take * immediate effect. The returned promise resolves once every in-flight read has finished. */ blockNewActivity(): Promise; /** * Track an in-flight data report read. Must be called synchronously before the first await in the handler so * there is no gap between the {@link isBlocked} check and the tracking. Use with `using` to guarantee cleanup: * * ```ts * using _reading = subscriptions.beginReading(); * await handleExchange(exchange); * ``` */ beginReading(): Disposable; /** * Register a user-facing {@link ClientSubscription}. */ addActive(subscription: ClientSubscription): void; /** * Register a {@link PeerSubscription}. */ addPeer(subscription: PeerSubscription): void; /** * Retrieve a {@link PeerSubscription} by ID. */ getPeer(address: PeerAddress, id: SubscriptionId): PeerSubscription | undefined; /** * Emits when a report the peer pushes starts arriving on one of its subscriptions, with the session it arrived * over. A priming report returned inline in the subscribe exchange does not emit. */ readonly reportStarted: Observable<[session: SecureSession], void>; /** * Close all {@link PeerSubscription}s for a specific peer, triggering re-subscription. */ closeForPeer(address: PeerAddress): void; /** * Unregister a {@link PeerSubscription}. */ delete(subscription: ClientSubscription): void; /** * Iterate over active subscriptions. */ [Symbol.iterator](): SetIterator; /** * Terminate all subscriptions. Also blocks and drains in-flight data report reads so that no new data is * processed after this method returns. */ close(): Promise; /** * Restart the timeout timer for the current set of active subscriptions. */ resetTimer(): void; } export declare namespace ClientSubscriptions { interface Listener { (reports: AsyncIterable): Promise; } } //# sourceMappingURL=ClientSubscriptions.d.ts.map