diff --git a/lib/node-redis-pubsub.js b/lib/node-redis-pubsub.js index 60c2944..45e7d08 100644 --- a/lib/node-redis-pubsub.js +++ b/lib/node-redis-pubsub.js @@ -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);