primus-cluster
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -52,3 +52,4 @@ /** | ||
/** | ||
* Get rooms socket is subscribed to. | ||
* Get the list of rooms joined by the socket or the list | ||
* of all active rooms. | ||
* | ||
@@ -62,3 +63,12 @@ * @param {String} id Socket id | ||
cb = cb || noop; | ||
this.client.smembers(socketKey.format(id), cb); | ||
if (id) return this.client.smembers(socketKey.format(id), cb); | ||
this.client.keys('room:*', function (err, rooms) { | ||
if (err) return cb(err); | ||
cb(undefined, rooms.map(function (room) { | ||
return room.slice(5); | ||
})); | ||
}); | ||
}; | ||
@@ -65,0 +75,0 @@ |
@@ -51,3 +51,6 @@ /** | ||
PrimusCluster.prototype.initializeClients = function initializeClients(options) { | ||
options = options || {}; | ||
options = _.defaults(options || {}, { | ||
host: '127.0.0.1', | ||
port: 6379 | ||
}); | ||
@@ -54,0 +57,0 @@ this.clients = {}; |
{ | ||
"name": "primus-cluster", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Scale Primus across multiple servers.", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -73,2 +73,10 @@ var redis = require('redis'); | ||
}); | ||
it('should return all rooms when the `id` argument is falsy', function (done) { | ||
adapter.get(null, function (err, rooms) { | ||
if (err) return done(err); | ||
expect(rooms).to.have.members(['my:room:name', 'my:second:room:name']); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -75,0 +83,0 @@ |
28200
813