/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { ReadResult } from "#action/response/ReadResult.js"; import { Bytes, Duration } from "@matter/general"; import { Status, TlvDataReport, TlvDataReportForSend, TlvInvokeRequest, TlvInvokeResponse, TlvInvokeResponseForSend, TlvReadRequest, TlvStream, TlvSubscribeRequest, TlvSubscribeResponse, TlvTimedRequest, TlvWriteRequest, TlvWriteResponse, TypeFromSchema } from "@matter/types"; import { Message } from "../codec/MessageCodec.js"; import { ExchangeProvider, NewExchangeOptions } from "../protocol/ExchangeProvider.js"; import { ExchangeReceiveOptions, ExchangeSendOptions, MessageExchange } from "../protocol/MessageExchange.js"; import { AttributeReportPayload, BaseDataReport, DataReportPayloadIterator, EventReportPayload } from "./AttributeDataEncoder.js"; import { SubscriptionId } from "./Subscription.js"; export declare enum MessageType { StatusResponse = 1, ReadRequest = 2, SubscribeRequest = 3, SubscribeResponse = 4, ReportData = 5, WriteRequest = 6, WriteResponse = 7, InvokeRequest = 8, InvokeResponse = 9, TimedRequest = 10 } export type ReadRequest = TypeFromSchema; export type DataReport = TypeFromSchema; export type SubscribeRequest = TypeFromSchema; export type SubscribeResponse = TypeFromSchema; export type InvokeRequest = TypeFromSchema; export type InvokeResponse = TypeFromSchema; export type InvokeResponseForSend = TypeFromSchema; export type TimedRequest = TypeFromSchema; export type WriteRequest = TypeFromSchema; export type WriteResponse = TypeFromSchema; declare class InteractionMessenger { #private; constructor(exchange: MessageExchange); get exchange(): MessageExchange; protected set exchange(value: MessageExchange); send(messageType: number, payload: Bytes, options?: ExchangeSendOptions): Promise; protected trackEndMessage(promise: Promise, errorMessage: string): void; sendStatus(status: Status, options?: ExchangeSendOptions): Promise; waitForSuccess(expectedMessageInfo: string, options?: { expectedProcessingTime?: Duration; timeout?: Duration; }): Promise; nextMessage(expectedMessageType: number, options?: ExchangeReceiveOptions, expectedMessageInfo?: string): Promise; anyNextMessage(expectedMessageInfo: string, options?: ExchangeReceiveOptions): Promise; close(): Promise; protected throwIfErrorStatusMessage(message: Message, logHint?: string): void; get session(): import("../index.js").Session; } export interface InteractionRecipient { handleReadRequest(exchange: MessageExchange, request: ReadRequest, message: Message): Promise<{ dataReport: DataReport; payload?: DataReportPayloadIterator; }>; handleWriteRequest(exchange: MessageExchange, request: WriteRequest, messenger: InteractionServerMessenger, message: Message): Promise; handleSubscribeRequest(exchange: MessageExchange, request: SubscribeRequest, messenger: InteractionServerMessenger, message: Message): Promise; handleInvokeRequest(exchange: MessageExchange, request: InvokeRequest, messenger: InteractionServerMessenger, message: Message): Promise; handleTimedRequest(exchange: MessageExchange, request: TimedRequest, message: Message): void; } export declare class InteractionServerMessenger extends InteractionMessenger { #private; /** * Send a Status Response, unless the Invoke or Write request decoded last carries SuppressResponse set to TRUE. * Then the transaction terminates silently. */ sendStatus(status: Status, options?: ExchangeSendOptions): Promise; nextMessage(expectedMessageType: number, options?: ExchangeReceiveOptions, expectedMessageInfo?: string): Promise; handleRequest(recipient: InteractionRecipient): Promise; /** * Handle a DataReport with a Payload Iterator for a DataReport to send, split them into multiple DataReport * messages and send them out based on the size. */ sendDataReport(options: { baseDataReport: BaseDataReport; forFabricFilteredRead: boolean; payload?: DataReportPayloadIterator; waitForAck?: boolean; suppressEmptyReport?: boolean; }): Promise; sendDataReportMessage(dataReport: TypeFromSchema, waitForAck?: boolean): Promise; /** * Convert a server interaction report to a DataReport entry * TODO remove when anything is migrated completely */ static convertServerInteractionReport(report: ReadResult.Report): AttributeReportPayload | EventReportPayload; /** * Send a WriteResponse message. */ sendWriteResponse(response: WriteResponse, options?: { logContext?: string; }): Promise; /** * Wait for and decode the next WriteRequest message (for chunked writes). */ readNextWriteRequest(): Promise<{ writeRequest: WriteRequest; message: Message; }>; /** * Send an intermediate InvokeResponse chunk with moreChunkedMessages=true and wait for Status.Success. * Returns true if a client acknowledged, and we should continue, false if a client terminated the chunked series. */ sendInvokeResponseChunk(response: InvokeResponseForSend): Promise; /** * Send the final InvokeResponse (without moreChunkedMessages flag). */ sendInvokeResponse(response: InvokeResponseForSend): Promise; } export declare class IncomingInteractionClientMessenger extends InteractionMessenger { #private; waitFor(expectedMessageInfo: string, messageType: number, options?: ExchangeReceiveOptions): Promise; /** * Read data reports as they come in on the wire. * * Data reports payloads are decoded but list attributes may be split across messages; these will require reassembly. */ readDataReports(options?: ExchangeReceiveOptions): AsyncGenerator; attributeReports: import("@matter/types").OptionalFieldType; nodeId: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; attributeId: import("@matter/types").OptionalFieldType; listIndex: import("@matter/types").OptionalFieldType; wildcardPathFlags: import("@matter/types").OptionalFieldType>; wildcardFilterConfigurationVersion: import("@matter/types").OptionalFieldType; }>>; status: import("@matter/types").FieldType; clusterStatus: import("@matter/types").OptionalFieldType; }>>; }>>; attributeData: import("@matter/types").OptionalFieldType; path: import("@matter/types").FieldType; nodeId: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; attributeId: import("@matter/types").OptionalFieldType; listIndex: import("@matter/types").OptionalFieldType; wildcardPathFlags: import("@matter/types").OptionalFieldType>; wildcardFilterConfigurationVersion: import("@matter/types").OptionalFieldType; }>>; data: import("@matter/types").FieldType; }>>; }>[]>; eventReports: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; eventId: import("@matter/types").OptionalFieldType; isUrgent: import("@matter/types").OptionalFieldType; }>>; status: import("@matter/types").FieldType; clusterStatus: import("@matter/types").OptionalFieldType; }>>; }>>; eventData: import("@matter/types").OptionalFieldType; endpointId: import("@matter/types").OptionalFieldType; clusterId: import("@matter/types").OptionalFieldType; eventId: import("@matter/types").OptionalFieldType; isUrgent: import("@matter/types").OptionalFieldType; }>>; eventNumber: import("@matter/types").FieldType; priority: import("@matter/types").FieldType; epochTimestamp: import("@matter/types").OptionalFieldType; systemTimestamp: import("@matter/types").OptionalFieldType; deltaEpochTimestamp: import("@matter/types").OptionalFieldType; deltaSystemTimestamp: import("@matter/types").OptionalFieldType; data: import("@matter/types").OptionalFieldType; }>>; }>[]>; moreChunkedMessages: import("@matter/types").OptionalFieldType; suppressResponse: import("@matter/types").OptionalFieldType; interactionModelRevision: import("@matter/types").OptionalFieldType; }>, void, unknown>; /** Whether the peer waits for our status on the last data report it sent. */ get reportAwaitsStatus(): boolean; /** The subscription ID of the last data report, if it had one. */ protected get reportSubscriptionId(): number | undefined; /** * Answers the peer's data report with INVALID_SUBSCRIPTION, which makes the peer terminate the subscription. * * @see {@link MatterSpecification.v161.Core} § 8.5 */ sendInvalidSubscription(subscriptionId?: SubscriptionId, options?: Pick): Promise; } export declare class InteractionClientMessenger extends IncomingInteractionClientMessenger { #private; static create(exchangeProvider: ExchangeProvider, options?: NewExchangeOptions): Promise; /** * Ends a subscribe interaction the client gave up, or that failed, before the peer confirmed the subscription. * * The peer holds the subscription from the moment it accepts the request, so it must learn that the client no * longer wants it. Answers the report the peer waits on with INVALID_SUBSCRIPTION. If there is none and * `awaitReport` is set, waits for the next message until `abort` or the usual response time and answers it if it * is a report. A SubscribeResponse cannot be answered; the peer then drops the subscription when its next report * is refused. * * `abort` never suppresses an owed answer: an abort that fired before the first transmission still sends it, once, * without retransmission, and a later abort stops the waits for its ack and retransmissions. Never throws. * * @see {@link MatterSpecification.v161.Core} § 8.5 */ abandonSubscription({ awaitReport, abort }: { awaitReport: boolean; abort?: AbortSignal; }): Promise; sendReadRequest(readRequest: ReadRequest, options?: ExchangeSendOptions): Promise; sendSubscribeRequest(subscribeRequest: SubscribeRequest, options?: ExchangeSendOptions): Promise; /** * Send an invoke command and handle chunked responses. * Returns a combined InvokeResponse with all responses from all chunks, or undefined if suppressResponse */ sendInvokeCommand(invokeRequest: InvokeRequest, options?: ExchangeSendOptions): Promise; /** * Send a write and return the WriteResponse, or undefined if suppressResponse. * * A write that does not fit one message is sent as several chunked WriteRequestMessages in this exchange. Each * chunk waits for its WriteResponse before the next is sent; the returned response carries the statuses of all * chunks. * * A list write whose ADDs carry a DataVersion sends its REPLACE as the last AttributeDataIB of a chunk. Once the * REPLACE succeeded, the ADDs are sent without DataVersion: the REPLACE changed the data version, so the held one * can no longer match. If the REPLACE failed, the ADDs keep it, so a version mismatch rejects them too. A timed or * suppressResponse write that fits one message is not chunked for this, as such a write cannot be chunked. * * @see {@link MatterSpecification.v161.Core} § 10.7.6.2 */ sendWriteCommand(writeRequest: WriteRequest, options?: ExchangeSendOptions): Promise; sendTimedRequest(timeout: Duration, options?: ExchangeSendOptions): Promise; interactionModelRevision: import("@matter/types").OptionalFieldType; }>>; private requestWithSuppressedResponse; private request; } export {}; //# sourceMappingURL=InteractionMessenger.d.ts.map