///
import { IClientPublishOptions, IClientSubscribeOptions, IPublishPacket, MqttClient, Packet } from "mqtt";
import { Observable } from "rxjs";
import { LifecycleBase } from "../misc";
import { SimpleLogger } from "../misc/Logger";
import { MQTTConnectOpts } from "../model";
export interface MqttMessage {
topic: string;
topicTokens: string[];
payload: Buffer;
packet: IPublishPacket;
}
export interface MqttConnectionInfo {
connected: boolean;
disconnecting: boolean;
disconnected: boolean;
reconnecting: boolean;
}
export interface MqttSubscription {
topic: string;
activate: () => void;
messages$: Observable;
active: Observable;
unsubscribe: () => void;
}
export declare class RxMqtt extends LifecycleBase {
readonly mqttOpts: MQTTConnectOpts;
static counter: number;
protected readonly log: SimpleLogger;
protected mqtt: MqttClient | undefined;
private _onConnect$;
onConnect$: Observable;
private _onDisconnect$;
onDisconnect$: Observable;
private _onReconnect$;
onReconnect$: Observable;
private _onError$;
onError$: Observable;
private _onOffline$;
onOffline$: Observable;
private _onMessage$;
onMessage$: Observable;
private observables;
private activateOnConnect;
get disconnecting(): boolean;
private _connectionInfo$;
connectionInfo$: Observable;
get connectionInfo(): MqttConnectionInfo;
constructor(mqttOpts: MQTTConnectOpts);
onInit(): Promise;
protected onConnect(): void;
protected onError(error: Error): void;
protected onOffline(): void;
protected onReconnect(): void;
protected onClose(): void;
protected onDisconnect(): void;
protected onEnd(): void;
protected updateConnectionInfo(): void;
publish(topic: string, message: string | Buffer | null | undefined, opts?: IClientPublishOptions): void;
publish$(topic: string, message: string | Buffer | null | undefined, opts?: IClientPublishOptions): Observable;
/**
* Subscribe to a mqtt topic and return an observable of messages.
* When the last Observable subscriber unsubscribes the mqtt topic will be unsubscribed as well.
*
* @param topic mqtt topic to be subscribed to.
* @param retained wether to treat the messages from this subscription as retained. MQTT subscriptions are kept to a minimum and no same topic will be subsribed to more than once.
* This is due to problems with some brokers (e.g. vernemq, nanomq) which will send all messages as many times as there are subscriptions even for the same topic.
* Due to this a 2nd, 3rd,... Observable subscriber to the same topic would never receive the retained messages from the server as these we sent only once in the beginning.
* When setting retained to true all these messages will be buffered in order and only once per topic and re-emitted for every "late" subscriber. Please note that this
* is also true for messages that were sent to the server without the retained message flag!
* @param opts subscription options, will default to {qos: 2}
* @returns An observable of messages.
*/
subscribe(topic: string, retained?: boolean, opts?: IClientSubscribeOptions): Observable;
private onMessage;
onDestroy(): Promise;
}