mirror of
https://github.com/makeplane/plane
synced 2025-08-07 19:59:33 +00:00
32 lines
876 B
TypeScript
32 lines
876 B
TypeScript
import type { Request } from "express";
|
|
import type { WebSocket as WS } from "ws";
|
|
import type { Hocuspocus } from "@hocuspocus/server";
|
|
import { logger } from "@plane/logger";
|
|
import { Controller, WebSocket } from "@plane/decorators";
|
|
|
|
@Controller("/collaboration")
|
|
export class CollaborationController {
|
|
private metrics = {
|
|
errors: 0,
|
|
};
|
|
|
|
constructor(private readonly hocusPocusServer: Hocuspocus) {}
|
|
|
|
@WebSocket("/")
|
|
handleConnection(ws: WS, req: Request) {
|
|
try {
|
|
// Initialize the connection with Hocuspocus
|
|
this.hocusPocusServer.handleConnection(ws, req);
|
|
|
|
// Set up error handling for the connection
|
|
ws.on("error", (error) => {
|
|
logger.error("WebSocket connection error:", error);
|
|
ws.close();
|
|
});
|
|
} catch (error) {
|
|
logger.error("WebSocket connection error:", error);
|
|
ws.close();
|
|
}
|
|
}
|
|
}
|