[WIKI-682] feat: hocuspocus v3 server migration (#7880)
* fix: hocuspocus v3 * fix: publishing messages across redis extension
This commit is contained in:
parent
e110ef55b8
commit
ee68895ad3
5 changed files with 139 additions and 166 deletions
|
|
@ -20,12 +20,11 @@ export class Redis extends HocuspocusRedis {
|
|||
const stringPayload = typeof payload === "string" ? payload : JSON.stringify(payload);
|
||||
const message = new OutgoingMessage(documentName).writeBroadcastStateless(stringPayload);
|
||||
|
||||
const emptyPrefix = Buffer.concat([Buffer.from([0])]);
|
||||
|
||||
return this.pub.publishBuffer(
|
||||
return this.pub.publish(
|
||||
// we're accessing the private method of the hocuspocus redis extension
|
||||
this["pubKey"](documentName),
|
||||
Buffer.concat([emptyPrefix, Buffer.from(message.toUint8Array())])
|
||||
// we're accessing the private method of the hocuspocus redis extension to encode the message
|
||||
this["encodeMessage"](message.toUint8Array())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Server, Hocuspocus } from "@hocuspocus/server";
|
||||
import { Hocuspocus } from "@hocuspocus/server";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
// env
|
||||
import { env } from "@/env";
|
||||
|
|
@ -36,7 +36,7 @@ export class HocusPocusServerManager {
|
|||
return this.server;
|
||||
}
|
||||
|
||||
this.server = Server.configure({
|
||||
this.server = new Hocuspocus({
|
||||
name: this.serverName,
|
||||
onAuthenticate,
|
||||
onStateless,
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ export class Server {
|
|||
|
||||
public async destroy() {
|
||||
if (this.hocuspocusServer) {
|
||||
await this.hocuspocusServer.destroy();
|
||||
logger.info("HocusPocus server closed gracefully.");
|
||||
this.hocuspocusServer.closeConnections();
|
||||
logger.info("HocusPocus connections closed gracefully.");
|
||||
}
|
||||
|
||||
await redisManager.disconnect();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue