/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Duration } from "@matter/general"; import type { Advertiser } from "./Advertiser.js"; import { ServiceDescription } from "./ServiceDescription.js"; /** * An advertisement for a discrete service. */ export declare abstract class Advertisement { #private; /** * The service advertised. * * This is a unique ID associated with the advertisement. */ readonly service: string; /** * The information advertised. */ readonly description: T; /** * The {@link Advertiser} that owns this advertisement. */ readonly advertiser: Advertiser; /** * Configuration options. */ readonly options: Advertisement.Options; constructor(advertiser: Advertiser, service: string, description: T, options?: Advertisement.Options); /** * Begin automatic broadcast. */ start(event: Advertiser.BroadcastEvent): void; /** * End automatic broadcast. */ stop(): void; /** * Notify the advertiser that a client connection to the advertised service is established. */ serviceConnected(): void; /** * Notify the advertiser that there is no client connection to the advertised service. */ serviceDisconnected(): void; /** * Close the advertisement but do not wait for the close to finish. * * The advertisement is still tracked by the advertiser until closed. */ cancel(): void; /** * Close the advertisement. */ close(): Promise; /** * Async setup logic. */ protected onCreate(): Promise; /** * Async cleanup logic. */ protected onClose(): Promise; /** * Indicates the advertisement has entered the extended-announcement period per core spec 5.4.2.5. */ protected get isExtendedAnnouncement(): boolean; /** * Indicates that broadcasts should omit private details. * * True during the extended-announcement period or when forced via {@link Advertisement.Options.omitPrivateDetails}. */ protected get isPrivacyMasked(): boolean; /** * Implement automatic advertising. */ protected abstract run(context: Advertisement.ActivityContext, event: Advertiser.BroadcastEvent): Promise; isCommissioning(): this is Advertisement | Advertisement; isOperational(): this is Advertisement; /** * Cancel a set of advertisements. */ static cancelAll(ads: Iterable): void; /** * Cancel a set of advertisements and wait for them to complete. */ static closeAll(ads: Iterable): Promise; /** * Identify other advertisers for the same service. The advertiser will close these automatically. */ abstract isDuplicate(other: Advertisement): boolean; /** * Total duration so far. */ get duration(): Duration; /** * True if the advertisement is actively broadcasting. */ get isBroadcasting(): boolean; protected dict(values?: Record): Record; } export declare namespace Advertisement { interface Options { /** * Set this to omit optional details from broadcasts that may affect privacy. * * Per core spec 5.4.2.3.1, the device always omits vendor ID, product ID and extended data during extended * announcement. Set this value to omit this fields unconditionally. */ omitPrivateDetails?: boolean; } interface ActivityContext { /** * Enter cancelable sleep. * * Throws {@link CanceledError} if interrupted. If thrown from {@link run} this will result in the promise * resolving. */ sleep(name: string, duration: Duration): Promise; /** True if the activity has been canceled. */ cancelled: boolean; } } //# sourceMappingURL=Advertisement.d.ts.map