Skip to content

Commit

Permalink
Added filter to ensure clients only receive retained messages for mat…
Browse files Browse the repository at this point in the history
…ching subscriptions.
  • Loading branch information
bgau committed Jun 30, 2017
1 parent 6e7201c commit 0001ca1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aedes-persistence-level",
"version": "3.0.0",
"version": "3.0.1",
"description": "LevelDB persistence for Aedes",
"main": "persistence.js",
"scripts": {
Expand Down
13 changes: 12 additions & 1 deletion persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,22 @@ LevelPersistence.prototype.storeRetained = function (packet, cb) {
}

LevelPersistence.prototype.createRetainedStream = function (pattern) {
var qlobber = new Qlobber(QlobberOpts)
qlobber.add(pattern, true)

return this._db.createValueStream({
gt: 'retained:',
lt: 'retained\xff',
valueEncoding: msgpack
})
}).pipe(
through.obj(
function (packet, encoding, deliver) {
if (qlobber.match(packet.topic).length) {
deliver(null, packet)
}
}
)
)
}

function withClientId (sub) {
Expand Down

0 comments on commit 0001ca1

Please sign in to comment.