Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
fix onQos2publish code & update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
btsimonh committed May 19, 2017
1 parent f06c665 commit 32f0714
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,26 +535,28 @@ Client.prototype.handleAuthorizePublish = function(err, success, packet) {
packet.payload = success;
}

var dopuback = function() {
// if qos2Puback, then if qos 2, don't just ignore the message, puback it
// by converting internally to qos 1.
// this fools mqtt.js into not holding all messages forever
if (packet.qos === 2){
switch(that.server.onQoS2publish){
case 'dropToQoS1':
packet.qos = 1;
break;
case 'disconnect':
if (!this._closed && !this._closing) {
that.close(null, "qos2 caused disconnect");
}
return;
break;
default:
break;
}
// Mosca does not support QoS2
// if onQoS2publish === 'dropToQoS1', don't just ignore QoS2 message, puback it
// by converting internally to qos 1.
// this fools mqtt.js into not holding all messages forever
// if onQoS2publish === 'disconnect', then break the client connection if QoS2
if (packet.qos === 2){
switch(that.server.onQoS2publish){
case 'dropToQoS1':
packet.qos = 1;
break;
case 'disconnect':
if (!this._closed && !this._closing) {
that.close(null, "qos2 caused disconnect");
}
return;
break;
default:
break;
}
}

var dopuback = function() {
if (packet.qos === 1 && !(that._closed || that._closing)) {
that.connection.puback({
messageId: packet.messageId
Expand Down

0 comments on commit 32f0714

Please sign in to comment.