mqtt 4.2.4 → 4.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/CONTRIBUTING.md +27 -27
- package/LICENSE.md +15 -15
- package/README.md +792 -784
- package/bin/mqtt.js +27 -27
- package/bin/pub.js +146 -146
- package/bin/sub.js +123 -123
- package/dist/mqtt.js +7466 -8450
- package/dist/mqtt.min.js +1 -1
- package/doc/help.txt +8 -8
- package/doc/publish.txt +26 -26
- package/doc/subscribe.txt +26 -26
- package/lib/client.js +1581 -1581
- package/lib/connect/ali.js +128 -128
- package/lib/connect/index.js +164 -177
- package/lib/connect/tcp.js +21 -21
- package/lib/connect/tls.js +45 -45
- package/lib/connect/ws.js +256 -255
- package/lib/connect/wx.js +134 -134
- package/lib/store.js +128 -128
- package/lib/validations.js +52 -52
- package/mqtt.js +17 -17
- package/package.json +109 -108
- package/types/index.d.ts +28 -27
- package/types/lib/client-options.d.ts +191 -191
- package/types/lib/client.d.ts +240 -232
- package/types/lib/connect/index.d.ts +10 -10
- package/types/lib/store-options.d.ts +6 -6
- package/types/lib/store.d.ts +46 -46
package/types/lib/client.d.ts
CHANGED
|
@@ -1,232 +1,240 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import * as events from 'events'
|
|
4
|
-
import {
|
|
5
|
-
IClientOptions,
|
|
6
|
-
IClientPublishOptions,
|
|
7
|
-
IClientSubscribeOptions,
|
|
8
|
-
IClientReconnectOptions
|
|
9
|
-
} from './client-options'
|
|
10
|
-
import { Store } from './store'
|
|
11
|
-
import { Packet, QoS } from 'mqtt-packet'
|
|
12
|
-
|
|
13
|
-
export interface ISubscriptionGrant {
|
|
14
|
-
/**
|
|
15
|
-
* is a subscribed to topic
|
|
16
|
-
*/
|
|
17
|
-
topic: string
|
|
18
|
-
/**
|
|
19
|
-
* is the granted qos level on it, may return 128 on error
|
|
20
|
-
*/
|
|
21
|
-
qos: QoS | number
|
|
22
|
-
/*
|
|
23
|
-
* no local flag
|
|
24
|
-
* */
|
|
25
|
-
nl?: boolean,
|
|
26
|
-
/*
|
|
27
|
-
* Retain As Published flag
|
|
28
|
-
* */
|
|
29
|
-
rap?: boolean,
|
|
30
|
-
/*
|
|
31
|
-
* Retain Handling option
|
|
32
|
-
* */
|
|
33
|
-
rh?: number
|
|
34
|
-
}
|
|
35
|
-
export interface ISubscriptionRequest {
|
|
36
|
-
/**
|
|
37
|
-
* is a subscribed to topic
|
|
38
|
-
*/
|
|
39
|
-
topic: string
|
|
40
|
-
/**
|
|
41
|
-
* is the granted qos level on it
|
|
42
|
-
*/
|
|
43
|
-
qos: QoS
|
|
44
|
-
/*
|
|
45
|
-
* no local flag
|
|
46
|
-
* */
|
|
47
|
-
nl?: boolean,
|
|
48
|
-
/*
|
|
49
|
-
* Retain As Published flag
|
|
50
|
-
* */
|
|
51
|
-
rap?: boolean,
|
|
52
|
-
/*
|
|
53
|
-
* Retain Handling option
|
|
54
|
-
* */
|
|
55
|
-
rh?: number
|
|
56
|
-
}
|
|
57
|
-
export interface ISubscriptionMap {
|
|
58
|
-
/**
|
|
59
|
-
* object which has topic names as object keys and as value the options, like {'test1': {qos: 0}, 'test2': {qos: 2}}.
|
|
60
|
-
*/
|
|
61
|
-
[topic: string]: {
|
|
62
|
-
qos: QoS,
|
|
63
|
-
nl?: boolean,
|
|
64
|
-
rap?: boolean,
|
|
65
|
-
rh?: number
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export declare type OnConnectCallback = (packet:
|
|
70
|
-
export declare type
|
|
71
|
-
export declare type
|
|
72
|
-
export declare type
|
|
73
|
-
export declare type
|
|
74
|
-
export declare type
|
|
75
|
-
export declare type
|
|
76
|
-
|
|
77
|
-
export
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
public
|
|
93
|
-
public
|
|
94
|
-
public
|
|
95
|
-
public
|
|
96
|
-
public
|
|
97
|
-
public
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
public on (event: '
|
|
104
|
-
public on (event: '
|
|
105
|
-
public on (event:
|
|
106
|
-
|
|
107
|
-
public
|
|
108
|
-
public
|
|
109
|
-
public
|
|
110
|
-
public
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @param {
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* @
|
|
153
|
-
* @
|
|
154
|
-
* @
|
|
155
|
-
* @
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
183
|
-
* @
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* @
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* @
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
*
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
import * as events from 'events'
|
|
4
|
+
import {
|
|
5
|
+
IClientOptions,
|
|
6
|
+
IClientPublishOptions,
|
|
7
|
+
IClientSubscribeOptions,
|
|
8
|
+
IClientReconnectOptions
|
|
9
|
+
} from './client-options'
|
|
10
|
+
import { Store } from './store'
|
|
11
|
+
import { Packet, IConnectPacket, IPublishPacket, IDisconnectPacket, QoS } from 'mqtt-packet'
|
|
12
|
+
|
|
13
|
+
export interface ISubscriptionGrant {
|
|
14
|
+
/**
|
|
15
|
+
* is a subscribed to topic
|
|
16
|
+
*/
|
|
17
|
+
topic: string
|
|
18
|
+
/**
|
|
19
|
+
* is the granted qos level on it, may return 128 on error
|
|
20
|
+
*/
|
|
21
|
+
qos: QoS | number
|
|
22
|
+
/*
|
|
23
|
+
* no local flag
|
|
24
|
+
* */
|
|
25
|
+
nl?: boolean,
|
|
26
|
+
/*
|
|
27
|
+
* Retain As Published flag
|
|
28
|
+
* */
|
|
29
|
+
rap?: boolean,
|
|
30
|
+
/*
|
|
31
|
+
* Retain Handling option
|
|
32
|
+
* */
|
|
33
|
+
rh?: number
|
|
34
|
+
}
|
|
35
|
+
export interface ISubscriptionRequest {
|
|
36
|
+
/**
|
|
37
|
+
* is a subscribed to topic
|
|
38
|
+
*/
|
|
39
|
+
topic: string
|
|
40
|
+
/**
|
|
41
|
+
* is the granted qos level on it
|
|
42
|
+
*/
|
|
43
|
+
qos: QoS
|
|
44
|
+
/*
|
|
45
|
+
* no local flag
|
|
46
|
+
* */
|
|
47
|
+
nl?: boolean,
|
|
48
|
+
/*
|
|
49
|
+
* Retain As Published flag
|
|
50
|
+
* */
|
|
51
|
+
rap?: boolean,
|
|
52
|
+
/*
|
|
53
|
+
* Retain Handling option
|
|
54
|
+
* */
|
|
55
|
+
rh?: number
|
|
56
|
+
}
|
|
57
|
+
export interface ISubscriptionMap {
|
|
58
|
+
/**
|
|
59
|
+
* object which has topic names as object keys and as value the options, like {'test1': {qos: 0}, 'test2': {qos: 2}}.
|
|
60
|
+
*/
|
|
61
|
+
[topic: string]: {
|
|
62
|
+
qos: QoS,
|
|
63
|
+
nl?: boolean,
|
|
64
|
+
rap?: boolean,
|
|
65
|
+
rh?: number
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare type OnConnectCallback = (packet: IConnectPacket) => void
|
|
70
|
+
export declare type OnDisconnectCallback = (packet: IDisconnectPacket) => void
|
|
71
|
+
export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void
|
|
72
|
+
export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void
|
|
73
|
+
export declare type OnPacketCallback = (packet: Packet) => void
|
|
74
|
+
export declare type OnCloseCallback = () => void
|
|
75
|
+
export declare type OnErrorCallback = (error: Error) => void
|
|
76
|
+
export declare type PacketCallback = (error?: Error, packet?: Packet) => any
|
|
77
|
+
export declare type CloseCallback = (error?: Error) => void
|
|
78
|
+
|
|
79
|
+
export interface IStream extends events.EventEmitter {
|
|
80
|
+
pipe (to: any): any
|
|
81
|
+
destroy (): any
|
|
82
|
+
end (): any
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* MqttClient constructor
|
|
86
|
+
*
|
|
87
|
+
* @param {Stream} stream - stream
|
|
88
|
+
* @param {Object} [options] - connection options
|
|
89
|
+
* (see Connection#connect)
|
|
90
|
+
*/
|
|
91
|
+
export declare class MqttClient extends events.EventEmitter {
|
|
92
|
+
public connected: boolean
|
|
93
|
+
public disconnecting: boolean
|
|
94
|
+
public disconnected: boolean
|
|
95
|
+
public reconnecting: boolean
|
|
96
|
+
public incomingStore: Store
|
|
97
|
+
public outgoingStore: Store
|
|
98
|
+
public options: IClientOptions
|
|
99
|
+
public queueQoSZero: boolean
|
|
100
|
+
|
|
101
|
+
constructor (streamBuilder: (client: MqttClient) => IStream, options: IClientOptions)
|
|
102
|
+
|
|
103
|
+
public on (event: 'connect', cb: OnConnectCallback): this
|
|
104
|
+
public on (event: 'message', cb: OnMessageCallback): this
|
|
105
|
+
public on (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
|
|
106
|
+
public on (event: 'disconnect', cb: OnDisconnectCallback): this
|
|
107
|
+
public on (event: 'error', cb: OnErrorCallback): this
|
|
108
|
+
public on (event: 'close', cb: OnCloseCallback): this
|
|
109
|
+
public on (event: 'end' | 'reconnect' | 'offline' | 'outgoingEmpty', cb: () => void): this
|
|
110
|
+
public on (event: string, cb: Function): this
|
|
111
|
+
|
|
112
|
+
public once (event: 'connect', cb: OnConnectCallback): this
|
|
113
|
+
public once (event: 'message', cb: OnMessageCallback): this
|
|
114
|
+
public once (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
|
|
115
|
+
public once (event: 'disconnect', cb: OnDisconnectCallback): this
|
|
116
|
+
public once (event: 'error', cb: OnErrorCallback): this
|
|
117
|
+
public once (event: 'close', cb: OnCloseCallback): this
|
|
118
|
+
public once (event: 'end' | 'reconnect' | 'offline' | 'outgoingEmpty', cb: () => void): this
|
|
119
|
+
public once (event: string, cb: Function): this
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* publish - publish <message> to <topic>
|
|
123
|
+
*
|
|
124
|
+
* @param {String} topic - topic to publish to
|
|
125
|
+
* @param {(String|Buffer)} message - message to publish
|
|
126
|
+
*
|
|
127
|
+
* @param {Object} [opts] - publish options, includes:
|
|
128
|
+
* @param {Number} [opts.qos] - qos level to publish on
|
|
129
|
+
* @param {Boolean} [opts.retain] - whether or not to retain the message
|
|
130
|
+
* @param {Function}[opts.cbStorePut] - function(){}
|
|
131
|
+
* called when message is put into `outgoingStore`
|
|
132
|
+
*
|
|
133
|
+
* @param {Function} [callback] - function(err){}
|
|
134
|
+
* called when publish succeeds or fails
|
|
135
|
+
*
|
|
136
|
+
* @returns {Client} this - for chaining
|
|
137
|
+
* @api public
|
|
138
|
+
*
|
|
139
|
+
* @example client.publish('topic', 'message')
|
|
140
|
+
* @example
|
|
141
|
+
* client.publish('topic', 'message', {qos: 1, retain: true})
|
|
142
|
+
* @example client.publish('topic', 'message', console.log)
|
|
143
|
+
*/
|
|
144
|
+
public publish (topic: string, message: string | Buffer,
|
|
145
|
+
opts: IClientPublishOptions, callback?: PacketCallback): this
|
|
146
|
+
public publish (topic: string, message: string | Buffer,
|
|
147
|
+
callback?: PacketCallback): this
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* subscribe - subscribe to <topic>
|
|
151
|
+
*
|
|
152
|
+
* @param {String, Array, Object} topic - topic(s) to subscribe to, supports objects in the form {'topic': qos}
|
|
153
|
+
* @param {Object} [opts] - optional subscription options, includes:
|
|
154
|
+
* @param {Number} [opts.qos] - subscribe qos level
|
|
155
|
+
* @param {Function} [callback] - function(err, granted){} where:
|
|
156
|
+
* {Error} err - subscription error (none at the moment!)
|
|
157
|
+
* {Array} granted - array of {topic: 't', qos: 0}
|
|
158
|
+
* @returns {MqttClient} this - for chaining
|
|
159
|
+
* @api public
|
|
160
|
+
* @example client.subscribe('topic')
|
|
161
|
+
* @example client.subscribe('topic', {qos: 1})
|
|
162
|
+
* @example client.subscribe({'topic': 0, 'topic2': 1}, console.log)
|
|
163
|
+
* @example client.subscribe('topic', console.log)
|
|
164
|
+
*/
|
|
165
|
+
public subscribe (topic:
|
|
166
|
+
string
|
|
167
|
+
| string[], opts: IClientSubscribeOptions, callback?: ClientSubscribeCallback): this
|
|
168
|
+
public subscribe (topic:
|
|
169
|
+
string
|
|
170
|
+
| string[]
|
|
171
|
+
| ISubscriptionMap, callback?: ClientSubscribeCallback): this
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* unsubscribe - unsubscribe from topic(s)
|
|
175
|
+
*
|
|
176
|
+
* @param {String, Array} topic - topics to unsubscribe from
|
|
177
|
+
* @param {Object} opts - opts of unsubscribe
|
|
178
|
+
* @param {Function} [callback] - callback fired on unsuback
|
|
179
|
+
* @returns {MqttClient} this - for chaining
|
|
180
|
+
* @api public
|
|
181
|
+
* @example client.unsubscribe('topic')
|
|
182
|
+
* @example client.unsubscribe('topic', console.log)
|
|
183
|
+
* @example client.unsubscribe('topic', opts, console.log)
|
|
184
|
+
*/
|
|
185
|
+
public unsubscribe (topic: string | string[], opts?: Object, callback?: PacketCallback): this
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* end - close connection
|
|
189
|
+
*
|
|
190
|
+
* @returns {MqttClient} this - for chaining
|
|
191
|
+
* @param {Boolean} force - do not wait for all in-flight messages to be acked
|
|
192
|
+
* @param {Object} opts - opts disconnect
|
|
193
|
+
* @param {Function} cb - called when the client has been closed
|
|
194
|
+
*
|
|
195
|
+
* @api public
|
|
196
|
+
*/
|
|
197
|
+
public end (force?: boolean, opts?: Object, cb?: CloseCallback): this
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* removeOutgoingMessage - remove a message in outgoing store
|
|
201
|
+
* the outgoing callback will be called withe Error('Message removed') if the message is removed
|
|
202
|
+
*
|
|
203
|
+
* @param {Number} mid - messageId to remove message
|
|
204
|
+
* @returns {MqttClient} this - for chaining
|
|
205
|
+
* @api public
|
|
206
|
+
*
|
|
207
|
+
* @example client.removeOutgoingMessage(client.getLastMessageId());
|
|
208
|
+
*/
|
|
209
|
+
public removeOutgoingMessage (mid: number): this
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* reconnect - connect again using the same options as connect()
|
|
213
|
+
*
|
|
214
|
+
* @param {Object} [opts] - optional reconnect options, includes:
|
|
215
|
+
* {Store} incomingStore - a store for the incoming packets
|
|
216
|
+
* {Store} outgoingStore - a store for the outgoing packets
|
|
217
|
+
* if opts is not given, current stores are used
|
|
218
|
+
*
|
|
219
|
+
* @returns {MqttClient} this - for chaining
|
|
220
|
+
*
|
|
221
|
+
* @api public
|
|
222
|
+
*/
|
|
223
|
+
public reconnect (opts?: IClientReconnectOptions): this
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Handle messages with backpressure support, one at a time.
|
|
227
|
+
* Override at will.
|
|
228
|
+
*
|
|
229
|
+
* @param packet packet the packet
|
|
230
|
+
* @param callback callback call when finished
|
|
231
|
+
* @api public
|
|
232
|
+
*/
|
|
233
|
+
public handleMessage (packet: Packet, callback: PacketCallback): void
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* getLastMessageId
|
|
237
|
+
*/
|
|
238
|
+
public getLastMessageId (): number
|
|
239
|
+
}
|
|
240
|
+
export { IClientOptions }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IClientOptions, MqttClient } from '../client'
|
|
2
|
-
/**
|
|
3
|
-
* connect - connect to an MQTT broker.
|
|
4
|
-
*
|
|
5
|
-
* @param {String} [brokerUrl] - url of the broker, optional
|
|
6
|
-
* @param {Object} opts - see MqttClient#constructor
|
|
7
|
-
*/
|
|
8
|
-
declare function connect (brokerUrl?: string | any, opts?: IClientOptions): MqttClient
|
|
9
|
-
export { connect }
|
|
10
|
-
export { MqttClient }
|
|
1
|
+
import { IClientOptions, MqttClient } from '../client'
|
|
2
|
+
/**
|
|
3
|
+
* connect - connect to an MQTT broker.
|
|
4
|
+
*
|
|
5
|
+
* @param {String} [brokerUrl] - url of the broker, optional
|
|
6
|
+
* @param {Object} opts - see MqttClient#constructor
|
|
7
|
+
*/
|
|
8
|
+
declare function connect (brokerUrl?: string | any, opts?: IClientOptions): MqttClient
|
|
9
|
+
export { connect }
|
|
10
|
+
export { MqttClient }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface IStoreOptions {
|
|
2
|
-
/**
|
|
3
|
-
* true, clear _inflights at close
|
|
4
|
-
*/
|
|
5
|
-
clean?: boolean
|
|
6
|
-
}
|
|
1
|
+
export interface IStoreOptions {
|
|
2
|
+
/**
|
|
3
|
+
* true, clear _inflights at close
|
|
4
|
+
*/
|
|
5
|
+
clean?: boolean
|
|
6
|
+
}
|
package/types/lib/store.d.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IStoreOptions
|
|
3
|
-
} from './store-options'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* In-memory implementation of the message store
|
|
7
|
-
* This can actually be saved into files.
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
declare class Store {
|
|
11
|
-
/**
|
|
12
|
-
* Store constructor
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} [options] - store options
|
|
15
|
-
*/
|
|
16
|
-
constructor (options: IStoreOptions)
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Adds a packet to the store, a packet is
|
|
20
|
-
* anything that has a messageId property.
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
public put (packet: any, cb?: Function): this
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Creates a stream with all the packets in the store
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
public createStream (): any
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* deletes a packet from the store.
|
|
33
|
-
*/
|
|
34
|
-
public del (packet: any, cb: Function): this
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* get a packet from the store.
|
|
38
|
-
*/
|
|
39
|
-
public get (packet: any, cb: Function): this
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Close the store
|
|
43
|
-
*/
|
|
44
|
-
public close (cb: Function): void
|
|
45
|
-
}
|
|
46
|
-
export { Store }
|
|
1
|
+
import {
|
|
2
|
+
IStoreOptions
|
|
3
|
+
} from './store-options'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* In-memory implementation of the message store
|
|
7
|
+
* This can actually be saved into files.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
declare class Store {
|
|
11
|
+
/**
|
|
12
|
+
* Store constructor
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} [options] - store options
|
|
15
|
+
*/
|
|
16
|
+
constructor (options: IStoreOptions)
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Adds a packet to the store, a packet is
|
|
20
|
+
* anything that has a messageId property.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
public put (packet: any, cb?: Function): this
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Creates a stream with all the packets in the store
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
public createStream (): any
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* deletes a packet from the store.
|
|
33
|
+
*/
|
|
34
|
+
public del (packet: any, cb: Function): this
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* get a packet from the store.
|
|
38
|
+
*/
|
|
39
|
+
public get (packet: any, cb: Function): this
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Close the store
|
|
43
|
+
*/
|
|
44
|
+
public close (cb: Function): void
|
|
45
|
+
}
|
|
46
|
+
export { Store }
|