@meddv/ngx-mqtt
Version:
This library isn't just a wrapper around MQTT.js for angular. It uses observables and takes care of subscription handling and message routing.
56 lines (55 loc) • 1.67 kB
TypeScript
import { MqttClient, IClientOptions, IClientPublishOptions, IStream, IConnackPacket } from 'mqtt';
import { IPacket } from "mqtt-packet";
export declare enum MqttConnectionState {
CLOSED = 0,
CONNECTING = 1,
CONNECTED = 2
}
export interface IMqttServiceOptions extends IClientOptions {
/**
* whether a new connection should be created
* on creating an instance of the service
*/
connectOnCreate?: boolean;
/** the hostname of the mqtt broker */
hostname?: string;
/** the port to connect with websocket to the broker */
port?: number;
/** the path parameters to connect to e.g. `/mqtt` */
path?: string;
protocol?: 'wss' | 'ws';
/** if the url is provided, hostname, port path and protocol are ignored */
url?: string;
}
export interface IMqttMessage extends IPacket {
/** the mqtt topic to which this message was published to */
topic: string;
/** the payload */
payload: Uint8Array;
/** the quality of service */
qos: number;
/** if this message is a retained message */
retain: boolean;
/** if this message is a duplicate */
dup: boolean;
}
export interface IPublishOptions extends IClientPublishOptions {
}
export interface IOnConnectEvent extends IConnackPacket {
}
export interface IOnErrorEvent extends Error {
type?: string;
}
export interface IOnMessageEvent extends IMqttMessage {
}
export interface IOnSubackEvent {
granted: boolean;
filter: string;
}
export interface IMqttClient extends MqttClient {
stream: IStream;
}
export interface IOnPacketsendEvent extends IPacket {
}
export interface IOnPacketreceiveEvent extends IPacket {
}