Created
September 2, 2016 20:55
-
-
Save GavinDmello/b5f3329244ffa8263fe34cf0b9cf44da to your computer and use it in GitHub Desktop.
Test implementation of client list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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