import { ESPMatterDiscoveryParamsInterface } from "../../types/io/input"; import { ESPRMMatterEventType } from "../../types/subscription"; import { ESPRMEventCallback, ESPRMEventCallbackInput } from "./EventSubscriptionModel/types"; /** * Extends base SDK `ESPRMUser` event methods with Matter local discovery events. * Keeps one unified `subscribe/unsubscribe` API surface for app developers. */ declare module "@espressif/rainmaker-base-sdk/ESPRMUser" { interface ESPRMUser { /** * Registers one or more callbacks for a user event. * For Matter discovery events, this automatically starts SDK-managed local discovery. * * Example: * ```ts * user.subscribe( * ESPRMMatterEventType.matterLocalDiscovery, * (event) => { * console.log("Discovered node:", event.nodeId, event.transportDetails); * }, * { serviceType: "_matter._tcp.", domain: "local." } * ); * ``` */ subscribe(event: ESPRMMatterEventType | string, callback: ESPRMEventCallbackInput, discoveryConfig?: ESPMatterDiscoveryParamsInterface): void; /** * Removes a specific callback from an event. * When the last Matter discovery callback is removed, SDK discovery listeners are cleaned up. * * Example: * ```ts * const onLost = (event: unknown) => console.log("Lost:", event); * user.subscribe(ESPRMMatterEventType.matterLocalDiscoveryLost, onLost); * user.unsubscribe(ESPRMMatterEventType.matterLocalDiscoveryLost, onLost); * ``` */ unsubscribe(event: ESPRMMatterEventType | string, callback: ESPRMEventCallback): void; /** * Triggers callbacks for the given event with the provided payload. * This is used internally by the SDK for discovery/lost dispatch and can also be used for custom events. * * Example: * ```ts * user.trigger("com.example.customEvent", { ok: true }); * ``` */ trigger(event: ESPRMMatterEventType | string, arg: unknown): void; /** * Clears callbacks for one event or all events. * Clearing Matter discovery events also performs associated discovery teardown when required. * * Example: * ```ts * user.removeAllCallbacks(ESPRMMatterEventType.matterLocalDiscovery); * user.removeAllCallbacks(); * ``` */ removeAllCallbacks(event?: ESPRMMatterEventType | string): void; } }