Skip to content

Commit

Permalink
[docs] Updated README with more usage examples. (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
haridas authored and darrachequesne committed Jan 12, 2017
1 parent b494b16 commit 6577494
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ var io = require('socket.io-emitter')({ host: '127.0.0.1', port: 6379 });
setInterval(function(){
io.emit('time', new Date);
}, 5000);
```
```js
// Different constructor options.

//1. Initialize with host:port string
var io = require('socket.io-emitter')("loaclhost:6379")
// 2. Initlize with host, port object.
var io = require('socket.io-emitter')({ host: '127.0.0.1', port: 6379 });
// 3. Can use other node_redis compatible client eg; ioredis.

var Redis = require("ioredis");
var redis = new Redis();
var io = require('socket.io-emitter')(redis);

// Make the emitter works with redis clustered environment.
var Cluster = new Redis.Cluster([
{
host: "localhost",
port: 6379
},
{
host: "localhost",
port: 6378
},
]);
var io = require('socket.io-emitter')(Cluster);

```

## API
Expand Down

0 comments on commit 6577494

Please sign in to comment.