-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwss.adapter.ts
More file actions
executable file
·38 lines (31 loc) · 1.18 KB
/
wss.adapter.ts
File metadata and controls
executable file
·38 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { INestApplication } from '@nestjs/common';
import { IoAdapter } from '@nestjs/platform-socket.io';
import { createAdapter } from '@socket.io/redis-adapter';
//import config from 'config';
import { NextFunction } from 'express';
import Redis from 'ioredis';
import { Server, ServerOptions, Socket } from 'socket.io';
import { verify } from 'jsonwebtoken';
//import { access_denied, account_blocked, access_token_expired_signature, authorization_failed } from '../common/errors';
import { cors_options_delegate } from '../cors.options';
//import { IAccessToken } from '../oauth/oauth.service';
//const jwt_settings = config.get<IJwtSettings>('JWT_SETTINGS');
export class CustomRedisIoAdapter extends IoAdapter {
constructor(
app: INestApplication,
private readonly sub_client: Redis,
private readonly pub_client: Redis
) {
super(app);
}
public createIOServer(port: number, options?: ServerOptions): Server {
const server = super.createIOServer(port, {
...options,
cors: cors_options_delegate,
allowEIO3: true,
});
server.adapter(createAdapter(this.pub_client, this.sub_client));
//console.log('hasdhhdwuhu');
return server;
}
}