Skip to content

Commit

Permalink
Add broadcast stateless exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
linspw committed Dec 11, 2023
1 parent 14e5676 commit 41d365f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/server/src/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,15 @@ export class Document extends Doc {
/**
* Broadcast stateless message to all connections
*/
public broadcastStateless(payload: string): void {
public broadcastStateless(payload: string, exclude?: Connection | Connection[]): void {
this.callbacks.beforeBroadcastStateless(this, payload)

const toExclude = Array.isArray(exclude) ? exclude : [exclude]

this.getConnections().forEach(connection => {
if (exclude && toExclude.includes(connection)) {
return
}
connection.sendStateless(payload)
})
}
Expand Down

0 comments on commit 41d365f

Please sign in to comment.