Skip to content

Instantly share code, notes, and snippets.

@GavinDmello
Created September 2, 2016 20:55
Show Gist options
  • Save GavinDmello/b5f3329244ffa8263fe34cf0b9cf44da to your computer and use it in GitHub Desktop.
Save GavinDmello/b5f3329244ffa8263fe34cf0b9cf44da to your computer and use it in GitHub Desktop.
Test implementation of client list
MemoryPersistence.prototype.getClientList = function (topic, cb) {
var that = this
getClients(topic, function getClients(clientList) {
var count = 0
cb(from2.obj(function match(size, next) {
if (count >= clientList.length) return next(null, null)
var chunk = clientList[count]
count++
next(null, chunk)
}))
})
function getClients(topic, done) {
var clientSubs = that._subscriptions
var keys = Object.keys(clientSubs)
var subs = []
keys.forEach(function clientKey (client, index) {
clientSubs[client].forEach(function (sub) {
console.log(sub)
if (sub.topic === topic) {
subs.push(sub.clientId)
}
})
if (index === keys.length - 1) {
done(subs)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment