@@ -196,9 +196,10 @@ io.adapter(redisAdapter({ pubClient: pub, subClient: sub }));
196
196
197
197
``` js
198
198
const io = require (' socket.io' )(3000 );
199
+ const redisAdapter = require (' socket.io-redis' );
199
200
const Redis = require (' ioredis' );
200
201
201
- const cluster = new Redis.Cluster ( [
202
+ const startupNodes = [
202
203
{
203
204
port: 6380 ,
204
205
host: ' 127.0.0.1'
@@ -207,16 +208,19 @@ const cluster = new Redis.Cluster([
207
208
port: 6381 ,
208
209
host: ' 127.0.0.1'
209
210
}
210
- ]) ;
211
+ ];
211
212
212
- const redisAdapter = require (' socket.io-redis' );
213
- io .adapter (redisAdapter ({ pubClient: cluster, subClient: cluster }));
213
+ io .adapter (redisAdapter ({
214
+ pubClient: new Redis.Cluster (startupNodes),
215
+ subClient: new Redis.Cluster (startupNodes)
216
+ }));
214
217
```
215
218
216
219
### Sentinel Example
217
220
218
221
``` js
219
222
const io = require (' socket.io' )(3000 );
223
+ const redisAdapter = require (' socket.io-redis' );
220
224
const Redis = require (' ioredis' );
221
225
222
226
const options = {
@@ -227,10 +231,10 @@ const options = {
227
231
name: ' master01'
228
232
};
229
233
230
- const pubClient = new Redis (options);
231
- const subClient = new Redis (options);
232
-
233
- io . adapter ( redisAdapter ({ pubClient : pubClient, subClient : subClient }));
234
+ io . adapter ( redisAdapter ({
235
+ pubClient : new Redis (options),
236
+ subClient : new Redis (options)
237
+ }));
234
238
```
235
239
236
240
## Protocol
0 commit comments