Skip to content

Commit

Permalink
Added get clientList for level
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinDmello committed Sep 17, 2016
1 parent e5670f8 commit eb4bdd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Example:

```js
var level = require('level')
var aedesPersistencelevel = require('aedes-perisistence-level')
var aedesPersistencelevel = require('aedes-persistence-level')

// instantiate a persistence instance
aedesPersistencelevel(level('./mydb'))
Expand Down
15 changes: 15 additions & 0 deletions persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ LevelPersistence.prototype.streamWill = function (brokers) {
}))
}

LevelPersistence.prototype.getClientList = function (topic) {
var valueStream = this._db.createValueStream({
gt: SUBSCRIPTIONS,
lt: SUBSCRIPTIONS + '\xff',
valueEncoding: msgpack
})

return pump(valueStream, through.obj(function (chunk, enc, cb) {
if (chunk.topic === topic) {
this.push(chunk.clientId)
}
cb()
}))
}

LevelPersistence.prototype.destroy = function (cb) {
this._db.close(cb)
}
Expand Down

0 comments on commit eb4bdd7

Please sign in to comment.