Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/node-redis-pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ var redis = require('redis');
*/
function NodeRedisPubsub(options){
if (!(this instanceof NodeRedisPubsub)){ return new NodeRedisPubsub(options); }

options || (options = {});

var auth = options.auth

options.port = options.port || 6379; // 6379 is Redis' default
options.host = options.host || '127.0.0.1';

function createClient() {
if (options.createClient) {
return options.createClient();
} else {
return redis.createClient(options);
}
};

// Need to create two Redis clients as one cannot be both in receiver and emitter mode
// I wonder why that is, by the way ...
this.emitter = redis.createClient(options);
this.receiver = redis.createClient(options);
this.emitter = createClient();
this.receiver = createClient();

if(auth){
this.emitter.auth(auth);
Expand Down