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