/** * @module mqttConn */ import type { AnyPacket, CodecOpts } from "../mqttPacket/mod.ts"; import type { ConnNext } from "../connNext/connNext.ts"; /** * Common MQTT connection error messages */ export declare const MqttConnError: { readonly invalidPacket: "Invalid Packet"; readonly packetTooLarge: "Packet too large"; readonly connectPacketTooLarge: "Connect Packet too large"; readonly UnexpectedEof: "Unexpected EOF"; }; export type SendResult = { sent: true; } | { sent: false; reason: "packetTooLarge" | "connectionClosed"; size?: number; }; /** * Read a complete MQTT packet from the connection * @param conn Connection to read from * @param codecOpts the CodecOpts * @returns Decoded MQTT packet * @throws Error if packet is invalid or too large */ export declare function readPacket(conn: ConnNext, codecOpts: CodecOpts, maxConnectPacketSize: number): Promise; /** * MQTT Connection class */ export declare class MqttConn { #private; /** Underlying connection */ readonly conn: ConnNext; /** Maximum Connect packet size */ readonly maxConnectPacketSize: number; /** codecOpts */ codecOpts: CodecOpts; /** Reason for connection closure if any */ private _reason; /** Whether connection is closed */ private _isClosed; /** * Create new MQTT connection * @param options Connection options * @param options.conn Underlying socket connection * @param options.maxConnectPacketSize Maximum allowed connect packet size * @param options.maxIncomingPacketSize Maximum allowed incoming packet size * @param options.maxOutGoingPacketSize Maximum allowed outgoing packet size * @param options.protocolLevel Supported protocolLevel */ constructor(options: { conn: ConnNext; maxConnectPacketSize?: number; } & Partial); /** Get reason for connection closure */ get reason(): string | undefined; /** Get remoteAddress */ get remoteAddress(): string; /** Return next packet. */ next(): Promise>; /** Async iterator. */ [Symbol.asyncIterator](): this; send(data: AnyPacket): Promise; /** Whether connection is closed */ get isClosed(): boolean; /** Close the connection */ close(): void; } //# sourceMappingURL=mqttConn.d.ts.map