mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
fix(core): disconnect ws when user logout (#8188)
This commit is contained in:
@@ -70,5 +70,7 @@ export class WorkspaceEngine extends Entity<{
|
||||
|
||||
override dispose(): void {
|
||||
this.forceStop();
|
||||
this.doc.dispose();
|
||||
this.awareness.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,10 @@ export class WorkspaceEngineService extends Service {
|
||||
constructor(private readonly workspaceScope: WorkspaceScope) {
|
||||
super();
|
||||
}
|
||||
|
||||
override dispose(): void {
|
||||
this._engine?.dispose();
|
||||
this._engine = null;
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { Awareness } from 'y-protocols/awareness.js';
|
||||
export interface AwarenessConnection {
|
||||
connect(awareness: Awareness): void;
|
||||
disconnect(): void;
|
||||
dispose?(): void;
|
||||
}
|
||||
|
||||
export class AwarenessEngine {
|
||||
@@ -15,4 +16,8 @@ export class AwarenessEngine {
|
||||
disconnect() {
|
||||
this.connections.forEach(connection => connection.disconnect());
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.connections.forEach(connection => connection.dispose?.());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,4 +219,9 @@ export class DocEngine {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.stop();
|
||||
this.server?.dispose?.();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,6 @@ export interface DocServer {
|
||||
waitForConnectingServer(signal: AbortSignal): Promise<void>;
|
||||
disconnectServer(): void;
|
||||
onInterrupted(cb: (reason: string) => void): void;
|
||||
|
||||
dispose?(): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user