mqtt-packet
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -42,2 +42,5 @@ /* Protocol - protocol constants */ | ||
/* Connack */ | ||
module.exports.SESSIONPRESENT_MASK = 0x01; | ||
/* Connect */ | ||
@@ -44,0 +47,0 @@ module.exports.USERNAME_MASK = 0x80; |
@@ -200,3 +200,4 @@ | ||
pos += writeLength(buffer, pos, 2); | ||
pos += writeNumber(buffer, pos, rc); | ||
buffer.writeUInt8(opts.sessionPresent && protocol.SESSIONPRESENT_MASK || 0, pos++); | ||
buffer.writeUInt8(rc, pos++); | ||
@@ -203,0 +204,0 @@ return buffer; |
{ | ||
"name": "mqtt-packet", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "Parse and generate MQTT packets like a breeze", | ||
@@ -5,0 +5,0 @@ "main": "mqtt.js", |
@@ -236,4 +236,4 @@ | ||
var packet = this.packet | ||
packet.returnCode = this._parseNum() | ||
packet.sessionPresent = !!(this._list.readUInt8(this._pos++) & constants.SESSIONPRESENT_MASK) | ||
packet.returnCode = this._list.readUInt8(this._pos) | ||
if(packet.returnCode === -1) | ||
@@ -240,0 +240,0 @@ return this.emit('error', new Error('cannot parse return code')) |
@@ -152,2 +152,3 @@ mqtt-packet [![Build Status](https://travis-ci.org/mqttjs/mqtt-packet.png)](https://travis-ci.org/mqttjs/mqtt-packet) | ||
, returnCode: 0 // or whatever else you see fit | ||
, sessionPresent: false // or true. | ||
} | ||
@@ -154,0 +155,0 @@ ``` |
18
test.js
@@ -261,2 +261,3 @@ | ||
, length: 2 | ||
, sessionPresent: false | ||
, returnCode: 0 | ||
@@ -267,2 +268,14 @@ }, new Buffer([ | ||
testParseGenerate('connack with return code 0 session present bit set', { | ||
cmd: 'connack' | ||
, retain: false | ||
, qos: 0 | ||
, dup: false | ||
, length: 2 | ||
, sessionPresent: true | ||
, returnCode: 0 | ||
}, new Buffer([ | ||
32, 2, 1, 0 | ||
])) | ||
testParseGenerate('connack with return code 5', { | ||
@@ -274,2 +287,3 @@ cmd: 'connack' | ||
, length: 2 | ||
, sessionPresent: false | ||
, returnCode: 5 | ||
@@ -764,1 +778,5 @@ }, new Buffer([ | ||
}) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50761
1579
329