@@ -196,9 +196,10 @@ io.adapter(redisAdapter({ pubClient: pub, subClient: sub }));
196196
197197``` js
198198const io = require (' socket.io' )(3000 );
199+ const redisAdapter = require (' socket.io-redis' );
199200const Redis = require (' ioredis' );
200201
201- const cluster = new Redis.Cluster ( [
202+ const startupNodes = [
202203 {
203204 port: 6380 ,
204205 host: ' 127.0.0.1'
@@ -207,16 +208,19 @@ const cluster = new Redis.Cluster([
207208 port: 6381 ,
208209 host: ' 127.0.0.1'
209210 }
210- ]) ;
211+ ];
211212
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+ }));
214217```
215218
216219### Sentinel Example
217220
218221``` js
219222const io = require (' socket.io' )(3000 );
223+ const redisAdapter = require (' socket.io-redis' );
220224const Redis = require (' ioredis' );
221225
222226const options = {
@@ -227,10 +231,10 @@ const options = {
227231 name: ' master01'
228232};
229233
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+ }));
234238```
235239
236240## Protocol
0 commit comments