/** * @module persistence * @description Module for handling MQTT message persistence and client management */ import type { ClientId, PacketId, PublishPacketV5, QoS, RetainHandling, TopicFilter } from "./deps.ts"; /** * extended publish packet also contains meta data */ export type ExtPublishPacket = PublishPacketV5 & { expiresAtMs?: number; }; /** * The MQTT topic share to subscribe/unsubscribe to */ export type ShareName = string; export type ClientSubscription = { topicFilter: TopicFilter; shareName: ShareName; qos: QoS; noLocal?: boolean; retainAsPublished?: boolean; retainHandling?: RetainHandling; subscriptionIdentifier?: number; }; /** * Maximum packet ID value for MQTT messages (0xffff/65535) */ export declare const MAX_PACKET_ID = 65535; export type Handler = (packet: ExtPublishPacket) => void | Promise; export type ClientRegistrationResult = { existingSession: boolean; }; /** * Interface for persistence implementations to store messages and subscriptions */ export interface Persistence { initialize(): Promise; registerClient(clientId: ClientId, handler: Handler): Promise; deregisterClient(clientId: ClientId): Promise; disconnectClient(clientId: ClientId): Promise; subscribe(clientId: ClientId, subscription: ClientSubscription): Promise; unsubscribe(clientId: ClientId, topicFilter: TopicFilter, shareName: ShareName): Promise; listSubscriptions(clientId: ClientId): AsyncIterableIterator; addPendingIncomingPacket(clientId: ClientId, packet: ExtPublishPacket): Promise; getPendingIncomingPacket(clientId: ClientId, packetId: PacketId): Promise; listPendingIncomingPackets(clientId: ClientId): AsyncIterableIterator; deletePendingIncomingPacket(clientId: ClientId, packetId: PacketId): Promise; addPendingOutgoingPacket(clientId: ClientId, packet: ExtPublishPacket): Promise; getPendingOutgoingPacket(clientId: ClientId, packetId: PacketId): Promise; updatePendingOutgoingPacket(clientId: ClientId, packetId: PacketId, dup: boolean): Promise; listPendingOutgoingPackets(clientId: ClientId): AsyncIterableIterator; deletePendingOutgoingPacket(clientId: ClientId, packetId: PacketId): Promise; addPendingAck(clientId: ClientId, packetId: PacketId): Promise; hasPendingAck(clientId: ClientId, packetId: PacketId): Promise; deletePendingAck(clientId: ClientId, packetId: PacketId): Promise; listPendingAcks(clientId: ClientId): AsyncIterableIterator; publish(clientId: ClientId, packet: ExtPublishPacket): Promise; handleRetained(clientId: ClientId, subscriptions: ClientSubscription[]): Promise; nextPacketId(clientId: ClientId): Promise; } //# sourceMappingURL=persistence.d.ts.map