Skip to content

Commit

Permalink
Check if packet is type 'publish'. Also, remove from the outgoing que…
Browse files Browse the repository at this point in the history
…ue only when the client is not clean
  • Loading branch information
cristi authored and cristi committed Apr 27, 2016
1 parent 473a33f commit d035c57
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ function Client (broker, conn) {
}

this.deliverQoS = function deliverQoS (_packet, cb) {
var _toForward = _packet
var toForward = _packet
if (_packet.cmd === 'publish') {
_toForward = that.broker.authorizeForward(that, _packet)
if (!_toForward) {
toForward = that.broker.authorizeForward(that, _packet)
if (!toForward) {
if (that.clean === false) {
that.broker.persistence.outgoingClearMessageId(that, _packet, nop)
}
Expand All @@ -87,10 +87,10 @@ function Client (broker, conn) {
}
}
// downgrade to qos0 if requested by publish
if (_toForward.qos === 0) {
that.deliver0(_toForward, cb)
if (toForward.qos === 0) {
that.deliver0(toForward, cb)
} else {
var packet = new QoSPacket(_toForward, that)
var packet = new QoSPacket(toForward, that)
packet.writeCallback = cb
broker.persistence.outgoingUpdate(that, packet, writeQoS)
}
Expand Down

0 comments on commit d035c57

Please sign in to comment.