Sending events to all clients in room

Hi all, I’m new to yjs and am finding it great so far, thanks! There’s one thing I haven’t worked out how to achieve though. I have a requirement to send a message to all other clients that are connected to the same doc to indicate that some event has happened and I can’t work out a way to do that. I’ve managed to get something working by setting awareness state and having all clients listen for awareness updates but it seems like something that would be better suited to a single one off event rather than adding it to a clients state.

I thought I may be able to use yjsProvider.emit(‘myEvent’, [‘some-data’]). And then listening for that event with yjsProvider.on(‘myEvent’, handler). But that only seems to trigger the handlers on the same client. Is there away to make emit send the update to all connected clients, or some other way of sending events to all clients?


I’m not aware of a way to do this in y-websocket, but it’s possible in hocuspocus: