diff --git a/packages/server/src/Document.ts b/packages/server/src/Document.ts index d12035a4..7e40c11b 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) }) }