File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,17 @@ Once the package is installed, we can create a `RedisIoAdapter` class.
37
37
38
38
``` typescript
39
39
import { IoAdapter } from ' @nestjs/platform-socket.io' ;
40
- import * as redisIoAdapter from ' socket.io-redis' ;
40
+ import { RedisClient } from ' redis' ;
41
+ import { ServerOptions } from ' socket.io' ;
42
+ import { createAdapter } from ' socket.io-redis' ;
43
+
44
+ const pubClient = new RedisClient ({ host: ' localhost' , port: 6379 });
45
+ const subClient = pubClient .duplicate ();
46
+ const redisAdapter = createAdapter ({ pubClient , subClient });
41
47
42
48
export class RedisIoAdapter extends IoAdapter {
43
- createIOServer(port : number , options ? : any ): any {
49
+ createIOServer(port : number , options ? : ServerOptions ): any {
44
50
const server = super .createIOServer (port , options );
45
- const redisAdapter = redisIoAdapter ({ host: ' localhost' , port: 6379 });
46
-
47
51
server .adapter (redisAdapter );
48
52
return server ;
49
53
}
You can’t perform that action at this time.
0 commit comments