Skip to content

Commit

Permalink
Merge pull request #8 from bgau/master
Browse files Browse the repository at this point in the history
retained messages / subscription filter
  • Loading branch information
mcollina authored Jun 30, 2017
2 parents 6e7201c + 0001ca1 commit f2da1ef
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 f2da1ef

Please sign in to comment.