mqtt 2.18.6 → 3.0.0

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/README.md CHANGED
@@ -56,6 +56,8 @@ which are `Buffer`.
56
56
  Another __breaking change__ is that MQTT.js now defaults to MQTT v3.1.1,
57
57
  so to support old brokers, please read the [client options doc](#client).
58
58
 
59
+ MQTT v5 support is experimental as it has not been implemented by brokers yet.
60
+
59
61
  <a name="install"></a>
60
62
  ## Installation
61
63
 
@@ -212,12 +214,36 @@ the `connect` event. Typically a `net.Socket`.
212
214
  * `incomingStore`: a [Store](#store) for the incoming packets
213
215
  * `outgoingStore`: a [Store](#store) for the outgoing packets
214
216
  * `queueQoSZero`: if connection is broken, queue outgoing QoS zero messages (default `true`)
217
+ * `customHandleAcks`: MQTT 5 feature of custom handling puback and pubrec packets. Its callback:
218
+ ```js
219
+ customHandleAcks: function(topic, message, packet, done) {*some logic wit colling done(error, reasonCode)*}
220
+ ```
221
+ * `properties`: properties MQTT 5.0.
222
+ `object` that supports the following properties:
223
+ * `sessionExpiryInterval`: representing the Session Expiry Interval in seconds `number`,
224
+ * `receiveMaximum`: representing the Receive Maximum value `number`,
225
+ * `maximumPacketSize`: representing the Maximum Packet Size the Client is willing to accept `number`,
226
+ * `topicAliasMaximum`: representing the Topic Alias Maximum value indicates the highest value that the Client will accept as a Topic Alias sent by the Server `number`,
227
+ * `requestResponseInformation`: The Client uses this value to request the Server to return Response Information in the CONNACK `boolean`,
228
+ * `requestProblemInformation`: The Client uses this value to indicate whether the Reason String or User Properties are sent in the case of failures `boolean`,
229
+ * `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`,
230
+ * `authenticationMethod`: the name of the authentication method used for extended authentication `string`,
231
+ * `authenticationData`: Binary Data containing authentication data `binary`
232
+ * `authPacket`: settings for auth packet `object`
215
233
  * `will`: a message that will sent by the broker automatically when
216
234
  the client disconnect badly. The format is:
217
235
  * `topic`: the topic to publish
218
236
  * `payload`: the message to publish
219
237
  * `qos`: the QoS
220
238
  * `retain`: the retain flag
239
+ * `properties`: properties of will by MQTT 5.0:
240
+ * `willDelayInterval`: representing the Will Delay Interval in seconds `number`,
241
+ * `payloadFormatIndicator`: Will Message is UTF-8 Encoded Character Data or not `boolean`,
242
+ * `messageExpiryInterval`: value is the lifetime of the Will Message in seconds and is sent as the Publication Expiry Interval when the Server publishes the Will Message `number`,
243
+ * `contentType`: describing the content of the Will Message `string`,
244
+ * `responseTopic`: String which is used as the Topic Name for a response message `string`,
245
+ * `correlationData`: The Correlation Data is used by the sender of the Request Message to identify which request the Response Message is for when it is received `binary`,
246
+ * `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`
221
247
  * `transformWsUrl` : optional `(url, options, client) => url` function
222
248
  For ws/wss protocols only. Can be used to implement signing
223
249
  urls which upon reconnect can have become expired.
@@ -265,6 +291,12 @@ Emitted when a reconnect starts.
265
291
 
266
292
  Emitted after a disconnection.
267
293
 
294
+ #### Event `'disconnect'`
295
+
296
+ `function (packet) {}`
297
+
298
+ Emitted after receiving disconnect packet from broker. MQTT 5.0 feature.
299
+
268
300
  #### Event `'offline'`
269
301
 
270
302
  `function () {}`
@@ -327,6 +359,16 @@ Publish a message to a topic
327
359
  * `qos` QoS level, `Number`, default `0`
328
360
  * `retain` retain flag, `Boolean`, default `false`
329
361
  * `dup` mark as duplicate flag, `Boolean`, default `false`
362
+ * `properties`: MQTT 5.0 properties `object`
363
+ * `payloadFormatIndicator`: Payload is UTF-8 Encoded Character Data or not `boolean`,
364
+ * `messageExpiryInterval`: the lifetime of the Application Message in seconds `number`,
365
+ * `topicAlias`: value that is used to identify the Topic instead of using the Topic Name `number`,
366
+ * `responseTopic`: String which is used as the Topic Name for a response message `string`,
367
+ * `correlationData`: used by the sender of the Request Message to identify which request the Response Message is for when it is received `binary`,
368
+ * `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`,
369
+ * `subscriptionIdentifier`: representing the identifier of the subscription `number`,
370
+ * `contentType`: String describing the content of the Application Message `string`
371
+ * `cbStorePut` - `function ()`, fired when message is put into `outgoingStore` if QoS is `1` or `2`.
330
372
  * `callback` - `function (err)`, fired when the QoS handling completes,
331
373
  or at the next tick if QoS 0. An error occurs if client is disconnecting.
332
374
 
@@ -338,10 +380,16 @@ Subscribe to a topic or topics
338
380
 
339
381
  * `topic` is a `String` topic to subscribe to or an `Array` of
340
382
  topics to subscribe to. It can also be an object, it has as object
341
- keys the topic name and as value the QoS, like `{'test1': 0, 'test2': 1}`.
383
+ keys the topic name and as value the QoS, like `{'test1': {qos: 0}, 'test2': {qos: 1}}`.
342
384
  MQTT `topic` wildcard characters are supported (`+` - for single level and `#` - for multi level)
343
385
  * `options` is the options to subscribe with, including:
344
386
  * `qos` qos subscription level, default 0
387
+ * `nl` No Local MQTT 5.0 flag (If the value is true, Application Messages MUST NOT be forwarded to a connection with a ClientID equal to the ClientID of the publishing connection)
388
+ * `rap` Retain as Published MQTT 5.0 flag (If true, Application Messages forwarded using this subscription keep the RETAIN flag they were published with. If false, Application Messages forwarded using this subscription have the RETAIN flag set to 0.)
389
+ * `rh` Retain Handling MQTT 5.0 (This option specifies whether retained messages are sent when the subscription is established.)
390
+ * `properties`: `object`
391
+ * `subscriptionIdentifier`: representing the identifier of the subscription `number`,
392
+ * `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`
345
393
  * `callback` - `function (err, granted)`
346
394
  callback fired on suback where:
347
395
  * `err` a subscription error or an error that occurs when client is disconnecting
@@ -351,22 +399,32 @@ Subscribe to a topic or topics
351
399
 
352
400
  -------------------------------------------------------
353
401
  <a name="unsubscribe"></a>
354
- ### mqtt.Client#unsubscribe(topic/topic array, [callback])
402
+ ### mqtt.Client#unsubscribe(topic/topic array, [options], [callback])
355
403
 
356
404
  Unsubscribe from a topic or topics
357
405
 
358
406
  * `topic` is a `String` topic or an array of topics to unsubscribe from
407
+ * `options`: options of unsubscribe.
408
+ * `properties`: `object`
409
+ * `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`
359
410
  * `callback` - `function (err)`, fired on unsuback. An error occurs if client is disconnecting.
360
411
 
361
412
  -------------------------------------------------------
362
413
  <a name="end"></a>
363
- ### mqtt.Client#end([force], [cb])
414
+ ### mqtt.Client#end([force], [options], [cb])
364
415
 
365
416
  Close the client, accepts the following options:
366
417
 
367
418
  * `force`: passing it to true will close the client right away, without
368
419
  waiting for the in-flight messages to be acked. This parameter is
369
420
  optional.
421
+ * `options`: options of disconnect.
422
+ * `reasonCode`: Disconnect Reason Code `number`
423
+ * `properties`: `object`
424
+ * `sessionExpiryInterval`: representing the Session Expiry Interval in seconds `number`,
425
+ * `reasonString`: representing the reason for the disconnect `string`,
426
+ * `userProperties`: The User Property is allowed to appear multiple times to represent multiple name, value pairs `object`,
427
+ * `serverReference`: String which can be used by the Client to identify another Server to use `string`
370
428
  * `cb`: will be called when the client is closed. This parameter is
371
429
  optional.
372
430
 
@@ -473,22 +531,40 @@ at https://unpkg.com/mqtt/dist/mqtt.min.js.
473
531
  See http://unpkg.com for the full documentation on version ranges.
474
532
 
475
533
  <a name="weapp"></a>
476
- ## Weixin App
477
- Surport [Weixin App](https://mp.weixin.qq.com/). See [Doc](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-socket.html).
534
+ ## WeChat Mini Program
535
+ Support [WeChat Mini Program](https://mp.weixin.qq.com/). See [Doc](https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-socket.html).
536
+ <a name="example"></a>
537
+
538
+ ## Example(js)
539
+
540
+ ```js
541
+ var mqtt = require('mqtt')
542
+ var client = mqtt.connect('wxs://test.mosquitto.org')
543
+ ```
544
+
545
+ ## Example(ts)
546
+
547
+ ```ts
548
+ import { connect } from 'mqtt';
549
+ const client = connect('wxs://test.mosquitto.org');
550
+ ```
551
+
552
+ ## Ali Mini Program
553
+ Surport [Ali Mini Program](https://open.alipay.com/channel/miniIndex.htm). See [Doc](https://docs.alipay.com/mini/developer/getting-started).
478
554
  <a name="example"></a>
479
555
 
480
556
  ## Example(js)
481
557
 
482
558
  ```js
483
559
  var mqtt = require('mqtt')
484
- var client = mqtt.connect('wxs://test.mosquitto.org')
560
+ var client = mqtt.connect('alis://test.mosquitto.org')
485
561
  ```
486
562
 
487
563
  ## Example(ts)
488
564
 
489
565
  ```ts
490
566
  import { connect } from 'mqtt';
491
- const client = connect('wxs://test.mosquitto.org');
567
+ const client = connect('alis://test.mosquitto.org');
492
568
  ```
493
569
 
494
570
  <a name="browserify"></a>
@@ -604,6 +680,7 @@ MQTT.js is only possible due to the excellent work of the following contributors
604
680
  <tr><th align="left">Adam Rudd</th><td><a href="https://github.com/adamvr">GitHub/adamvr</a></td><td><a href="http://twitter.com/adam_vr">Twitter/@adam_vr</a></td></tr>
605
681
  <tr><th align="left">Matteo Collina</th><td><a href="https://github.com/mcollina">GitHub/mcollina</a></td><td><a href="http://twitter.com/matteocollina">Twitter/@matteocollina</a></td></tr>
606
682
  <tr><th align="left">Maxime Agor</th><td><a href="https://github.com/4rzael">GitHub/4rzael</a></td><td><a href="http://twitter.com/4rzael">Twitter/@4rzael</a></td></tr>
683
+ <tr><th align="left">Siarhei Buntsevich</th><td><a href="https://github.com/scarry1992">GitHub/scarry1992</a></td></tr>
607
684
  </tbody></table>
608
685
 
609
686
  <a name="license"></a>