mirror of
https://github.com/docmost/docmost.git
synced 2025-11-18 14:31:14 +10:00
switch to nx monorepo
This commit is contained in:
34
apps/server/src/collaboration/collaboration.gateway.ts
Normal file
34
apps/server/src/collaboration/collaboration.gateway.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Server as HocuspocusServer } from '@hocuspocus/server';
|
||||
import { IncomingMessage } from 'http';
|
||||
import WebSocket from 'ws';
|
||||
import { AuthenticationExtension } from './extensions/authentication.extension';
|
||||
import { PersistenceExtension } from './extensions/persistence.extension';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { HistoryExtension } from './extensions/history.extension';
|
||||
|
||||
@Injectable()
|
||||
export class CollaborationGateway {
|
||||
constructor(
|
||||
private authenticationExtension: AuthenticationExtension,
|
||||
private persistenceExtension: PersistenceExtension,
|
||||
private historyExtension: HistoryExtension,
|
||||
) {}
|
||||
|
||||
private hocuspocus = HocuspocusServer.configure({
|
||||
debounce: 5000,
|
||||
maxDebounce: 10000,
|
||||
extensions: [
|
||||
this.authenticationExtension,
|
||||
this.persistenceExtension,
|
||||
this.historyExtension,
|
||||
],
|
||||
});
|
||||
|
||||
handleConnection(client: WebSocket, request: IncomingMessage): any {
|
||||
this.hocuspocus.handleConnection(client, request);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.hocuspocus.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user