/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { SustainedClientSubscribe } from "#action/client/subscription/ClientSubscribe.js"; import { Read } from "#action/request/Read.js"; import { Subscribe } from "#action/request/Subscribe.js"; import { ReadResult } from "#action/response/ReadResult.js"; import type { IcdPeerWakefulness } from "#icd/IcdPeerWakefulness.js"; import { AsyncObservableValue, Duration, Observable, RetrySchedule } from "@matter/general"; import { type EventNumber, type NodeId, SubscribeResponse } from "@matter/types"; import { ClientSubscription } from "./ClientSubscription.js"; import { PeerSubscription } from "./PeerSubscription.js"; /** * An {@link ActiveSubscription} that remains active regardless of the state of the peer. * * This class performs retries in response to connection errors and timeouts. The underlying Matter subscription and * thus {@link ActiveSubscription#subscriptionId} may change if the peer goes offline or experiences transient errors. * * When a peer is a LIT (Long Idle Time) ICD operating in await mode, the subscription instead parks on the peer's wake * signal (a Check-In or any message from the peer) and (re)subscribes only when the peer becomes awake. Wakefulness * is read live via the {@link SustainedSubscription.Configuration#wakefulness} provider, so a peer registered after * construction is honored on the loop's next iteration. A runtime SIT⇄LIT operating-mode flip recreates the * subscription so its intervals are renegotiated for the new mode. * * Each replacement subscription requests only events above {@link maxEventNumber}. When our own processing of a * report fails, the failure is logged, the events pulled from the report before the failure count as seen and the * subscription continues. * * TODO - need to make underlying exchange provider abortable and work out how the retry schedule at this level * interacts with the MDNS and secure protocol retries. Will require some refactoring at lower levels. Leaving * retries at this level relatively conservative for now */ export declare class SustainedSubscription extends ClientSubscription { #private; /** Bounded retry interval used only on the degraded path where a once-LIT peer no longer requires await. */ static readonly SIT_RETRY_INTERVAL: Duration; constructor(config: SustainedSubscription.Configuration); /** * Emits when the active state changes. */ get active(): AsyncObservableValue<[any, ...any[]]>; /** * Emits when inactive state changes. */ get inactive(): AsyncObservableValue<[any, ...any[]]>; /** * The highest event number of the results this subscription processed, or undefined before the first event. An * event counts once {@link SustainedClientSubscribe.updated} pulled it and settled for its result. The number * never decreases. Until it is set, requests carry the `eventFilters` the request and its `refreshRequest` give. * * @see {@link MatterSpecification.v161.Core} § 8.9.3.1 */ get maxEventNumber(): EventNumber | undefined; get interactionModelRevision(): number | undefined; get maxInterval(): number; } export declare namespace SustainedSubscription { /** * Configuration for {@link SustainedSubscription}. */ interface Configuration extends Omit { request: SustainedClientSubscribe; /** * Function to establish underlying subscription. */ subscribe: (request: Subscribe, abort: AbortSignal) => Promise; /** * Performs bootstrap read. */ read: (request: Read, abort: AbortSignal) => ReadResult; /** * Probe the peer with an empty read to verify session liveness. */ probe: (abort: AbortSignal) => Promise; /** * The schedule we use for retrying subscription connections. * * We handle reconnection separately at the exchange level. This retry schedule only applies to establishing a * subscription once we have an active exchange. Exchange reconnection is handled by lower-level components. */ retries: RetrySchedule; /** * Live provider of the peer's {@link IcdPeerWakefulness}. Read on each loop decision so a peer registered after * construction, or flipped SIT⇄LIT at runtime, is honored on the next iteration. When it * returns a wakefulness in await mode (`requiresAwait`), the subscription parks on the wake signal instead of * probing/retrying; otherwise behavior is identical to a non-ICD sustained subscription. */ wakefulness?: () => IcdPeerWakefulness | undefined; /** * Live provider of the fabric ICD registry's "peer fed" signal, emitting the peer node ID whenever a peer's * registration starts. A subscription running without a wakefulness has no mode flip to observe, so it races * this signal and recreates through the normal mode-flip path once the peer is registered. */ peerFed?: () => Observable<[NodeId]> | undefined; } function assert(subscription: SubscribeResponse): asserts subscription is SustainedSubscription; const DefaultRetrySchedule: RetrySchedule.Configuration; } //# sourceMappingURL=SustainedSubscription.d.ts.map