From 3e179c0fb6ea70f29937c39979b3de50bb47d366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jess=C3=A9=20Correia=20Lins?= Date: Wed, 31 Jan 2024 16:58:30 -0300 Subject: [PATCH] Adding the possibility of not applying broadcast to specific connections (#757) * Add broadcast stateless exclude * adjust implementation --- packages/server/src/Document.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/server/src/Document.ts b/packages/server/src/Document.ts index d12035a49..7e40c11b4 100644 --- a/packages/server/src/Document.ts +++ b/packages/server/src/Document.ts @@ -248,10 +248,12 @@ export class Document extends Doc { /** * Broadcast stateless message to all connections */ - public broadcastStateless(payload: string): void { + public broadcastStateless(payload: string, filter?: (conn: Connection) => boolean): void { this.callbacks.beforeBroadcastStateless(this, payload) - this.getConnections().forEach(connection => { + const connections = filter ? this.getConnections().filter(filter) : this.getConnections() + + connections.forEach(connection => { connection.sendStateless(payload) }) }