mirror of
https://github.com/immich-app/immich.git
synced 2025-12-12 00:18:22 -05:00
21 lines
720 B
TypeScript
21 lines
720 B
TypeScript
import { INestApplicationContext } from '@nestjs/common';
|
|
import { IoAdapter } from '@nestjs/platform-socket.io';
|
|
import { createAdapter } from '@socket.io/redis-adapter';
|
|
import { Redis } from 'ioredis';
|
|
import { ServerOptions } from 'socket.io';
|
|
import { parseRedisConfig } from 'src/config';
|
|
|
|
export class WebSocketAdapter extends IoAdapter {
|
|
constructor(private app: INestApplicationContext) {
|
|
super(app);
|
|
}
|
|
|
|
createIOServer(port: number, options?: ServerOptions): any {
|
|
const server = super.createIOServer(port, options);
|
|
const pubClient = new Redis(parseRedisConfig());
|
|
const subClient = pubClient.duplicate();
|
|
server.adapter(createAdapter(pubClient, subClient));
|
|
return server;
|
|
}
|
|
}
|