Skip to content

Commit e8e8b01

Browse files
committed
Merge pull request #95 from omrilitov/master
Add support to ioredis
2 parents f758337 + 40fd543 commit e8e8b01

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ results
1313

1414
npm-debug.log
1515
node_modules
16+
.idea

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The following options are allowed:
3232
- `key`: the name of the key to pub/sub events on as prefix (`socket.io`)
3333
- `host`: host to connect to redis on (`localhost`)
3434
- `port`: port to connect to redis on (`6379`)
35+
- `subEvent`: optional, the redis client event name to subscribe to (`message`)
3536
- `pubClient`: optional, the redis client to publish events on
3637
- `subClient`: optional, the redis client to subscribe to events on
3738

@@ -42,6 +43,9 @@ with an equivalent API.
4243
If you supply clients, make sure you initialized them with
4344
the `return_buffers` option set to `true`.
4445

46+
You can supply [ioredis](https://github.com/luin/ioredis) as a client
47+
by providing `messageBuffer` as the subEvent option.
48+
4549
### RedisAdapter
4650

4751
The redis adapter instances expose the following properties

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function adapter(uri, opts){
4747
var pub = opts.pubClient;
4848
var sub = opts.subClient;
4949
var prefix = opts.key || 'socket.io';
50+
var subEvent = opts.subEvent || 'message';
5051

5152
// init clients if needed
5253
if (!pub) pub = redis(port, host);
@@ -74,7 +75,7 @@ function adapter(uri, opts){
7475
sub.subscribe(prefix + '#' + nsp.name + '#', function(err){
7576
if (err) self.emit('error', err);
7677
});
77-
sub.on('message', this.onmessage.bind(this));
78+
sub.on(subEvent, this.onmessage.bind(this));
7879
}
7980

8081
/**

0 commit comments

Comments
 (0)