Skip to content

Commit

Permalink
Adding the possibility of not applying broadcast to specific connecti…
Browse files Browse the repository at this point in the history
…ons (#757)

* Add broadcast stateless exclude

* adjust implementation
  • Loading branch information
linspw authored Jan 31, 2024
1 parent 23246f7 commit 3e179c0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/server/src/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit 3e179c0

Please sign in to comment.