mirror of
https://github.com/docmost/docmost.git
synced 2026-05-24 11:12:42 +08:00
pass wsAdapter to gateway
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
|||||||
import { WsSocketWrapper } from './extensions/redis-sync/ws-socket-wrapper';
|
import { WsSocketWrapper } from './extensions/redis-sync/ws-socket-wrapper';
|
||||||
import RedisClient from 'ioredis';
|
import RedisClient from 'ioredis';
|
||||||
import { pack, unpack } from 'msgpackr';
|
import { pack, unpack } from 'msgpackr';
|
||||||
|
import { CollabWsAdapter } from './adapter/collab-ws.adapter';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CollaborationGateway {
|
export class CollaborationGateway {
|
||||||
@@ -122,8 +123,7 @@ export class CollaborationGateway {
|
|||||||
return this.hocuspocus.getDocumentsCount();
|
return this.hocuspocus.getDocumentsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
async destroy(): Promise<void> {
|
async destroy(collabWsAdapter: CollabWsAdapter): Promise<void> {
|
||||||
await new Promise((r) => setTimeout(r, 10000));
|
|
||||||
// eslint-disable-next-line no-async-promise-executor
|
// eslint-disable-next-line no-async-promise-executor
|
||||||
await new Promise(async (resolve) => {
|
await new Promise(async (resolve) => {
|
||||||
try {
|
try {
|
||||||
@@ -134,6 +134,8 @@ export class CollaborationGateway {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
collabWsAdapter?.close();
|
||||||
|
|
||||||
if (this.hocuspocus.getDocumentsCount() === 0) resolve('');
|
if (this.hocuspocus.getDocumentsCount() === 0) resolve('');
|
||||||
this.hocuspocus.closeConnections();
|
this.hocuspocus.closeConnections();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ export class CollaborationModule implements OnModuleInit, OnModuleDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onModuleDestroy(): Promise<void> {
|
async onModuleDestroy(): Promise<void> {
|
||||||
this.collabWsAdapter?.close();
|
await this.collaborationGateway?.destroy(this.collabWsAdapter);
|
||||||
await this.collaborationGateway?.destroy();
|
|
||||||
this.collabWsAdapter?.destroy();
|
this.collabWsAdapter?.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user