ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.29k stars 125 forks source link

Adding the possibility of not applying broadcast to specific connections #757

Closed linspw closed 9 months ago

linspw commented 10 months ago

This is an implementation based on @grootgordon suggestion https://github.com/ueberdosis/hocuspocus/issues/618

janthurau commented 10 months ago

Thanks for your PR! The change looks a bit special, as you could also just do it manually and usually the broadcast really should send to everyone.

I think if we can add something like a filter function, it makes it more suitable for other scenarios as well. What do you think?

public broadcastStateless(payload: string, filter?: (conn: Connection) => boolean): void

linspw commented 9 months ago

Thank you very much for the answer and sorry for my delay, I adjusted the implementation, what you said makes more sense @janthurau