|
| 1 | +/** |
| 2 | + * @see https://github.com/mqttjs/MQTT.js/ |
| 3 | + */ |
| 4 | +export declare type QoS = 0 | 1 | 2; |
| 5 | + |
| 6 | +export interface MqttClientOptions extends ISecureClientOptions { |
| 7 | + port?: number; // port is made into a number subsequently |
| 8 | + host?: string; // host does NOT include port |
| 9 | + hostname?: string; |
| 10 | + path?: string; |
| 11 | + protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs'; |
| 12 | + |
| 13 | + wsOptions?: { |
| 14 | + [x: string]: any; |
| 15 | + }; |
| 16 | + /** |
| 17 | + * 10 seconds, set to 0 to disable |
| 18 | + */ |
| 19 | + keepalive?: number; |
| 20 | + /** |
| 21 | + * 'mqttjs_' + Math.random().toString(16).substr(2, 8) |
| 22 | + */ |
| 23 | + clientId?: string; |
| 24 | + /** |
| 25 | + * 'MQTT' |
| 26 | + */ |
| 27 | + protocolId?: string; |
| 28 | + /** |
| 29 | + * 4 |
| 30 | + */ |
| 31 | + protocolVersion?: number; |
| 32 | + /** |
| 33 | + * true, set to false to receive QoS 1 and 2 messages while offline |
| 34 | + */ |
| 35 | + clean?: boolean; |
| 36 | + /** |
| 37 | + * 1000 milliseconds, interval between two reconnections |
| 38 | + */ |
| 39 | + reconnectPeriod?: number; |
| 40 | + /** |
| 41 | + * 30 * 1000 milliseconds, time to wait before a CONNACK is received |
| 42 | + */ |
| 43 | + connectTimeout?: number; |
| 44 | + /** |
| 45 | + * the username required by your broker, if any |
| 46 | + */ |
| 47 | + username?: string; |
| 48 | + /** |
| 49 | + * the password required by your broker, if any |
| 50 | + */ |
| 51 | + password?: string; |
| 52 | + /** |
| 53 | + * a any for the incoming packets |
| 54 | + */ |
| 55 | + incomingStore?: any; |
| 56 | + /** |
| 57 | + * a any for the outgoing packets |
| 58 | + */ |
| 59 | + outgoingStore?: any; |
| 60 | + queueQoSZero?: boolean; |
| 61 | + reschedulePings?: boolean; |
| 62 | + servers?: Array<{ |
| 63 | + host: string; |
| 64 | + port: number; |
| 65 | + }>; |
| 66 | + /** |
| 67 | + * true, set to false to disable re-subscribe functionality |
| 68 | + */ |
| 69 | + resubscribe?: boolean; |
| 70 | + /** |
| 71 | + * a message that will sent by the broker automatically when the client disconnect badly. |
| 72 | + */ |
| 73 | + will?: { |
| 74 | + /** |
| 75 | + * the topic to publish |
| 76 | + */ |
| 77 | + topic: string; |
| 78 | + /** |
| 79 | + * the message to publish |
| 80 | + */ |
| 81 | + payload: string; |
| 82 | + /** |
| 83 | + * the QoS |
| 84 | + */ |
| 85 | + qos: QoS; |
| 86 | + /** |
| 87 | + * the retain flag |
| 88 | + */ |
| 89 | + retain: boolean; |
| 90 | + }; |
| 91 | + transformWsUrl?: ( |
| 92 | + url: string, |
| 93 | + options: any, |
| 94 | + client: any, |
| 95 | + ) => string; |
| 96 | +} |
| 97 | +export interface ISecureClientOptions { |
| 98 | + /** |
| 99 | + * optional private keys in PEM format |
| 100 | + */ |
| 101 | + key?: string | string[] | Buffer | Buffer[] | Object[]; |
| 102 | + /** |
| 103 | + * optional cert chains in PEM format |
| 104 | + */ |
| 105 | + cert?: string | string[] | Buffer | Buffer[]; |
| 106 | + /** |
| 107 | + * Optionally override the trusted CA certificates in PEM format |
| 108 | + */ |
| 109 | + ca?: string | string[] | Buffer | Buffer[]; |
| 110 | + rejectUnauthorized?: boolean; |
| 111 | +} |
| 112 | +export interface IClientPublishOptions { |
| 113 | + /** |
| 114 | + * the QoS |
| 115 | + */ |
| 116 | + qos: QoS; |
| 117 | + /** |
| 118 | + * the retain flag |
| 119 | + */ |
| 120 | + retain?: boolean; |
| 121 | + /** |
| 122 | + * whether or not mark a message as duplicate |
| 123 | + */ |
| 124 | + dup?: boolean; |
| 125 | +} |
| 126 | +export interface IClientSubscribeOptions { |
| 127 | + /** |
| 128 | + * the QoS |
| 129 | + */ |
| 130 | + qos: QoS; |
| 131 | +} |
| 132 | +export interface IClientReconnectOptions { |
| 133 | + /** |
| 134 | + * a any for the incoming packets |
| 135 | + */ |
| 136 | + incomingStore?: any; |
| 137 | + /** |
| 138 | + * a any for the outgoing packets |
| 139 | + */ |
| 140 | + outgoingStore?: any; |
| 141 | +} |
0 commit comments