Broadcast messages on awareness (posting copy from chat)

Hi everyone, love this library been using it for a live cursors. I’m using the y-websocket provider and it’s working well.
I’d like to know what is the recommended way to propagate user status log messages.
EXAMPLE :
A user performs an action, I want to display that users action on a running log message output
OPTIONS :
A : Use awareness protocol and setLocalStateField (‘userlog’), then get the states and print the log on the other users windows
B : Use the Y.doc with a shared log?
Using socket.io I’d just do a broadcast to the room and each client would keep their own append-only log, is there an equivalent using the awareness protocol? Should I drop down to the websocket level and implement it there?

So I found a way with awareness setting a state field and then immediately clearing it

awarenessDoc.setLocalStateField('broadcastMsg',msg);
awarenessDoc.setLocalStateField('broadcastMsg',null);

Hi @wernerstucky,

The Awareness protocol (which works similarly to a socket.io broadcast) doesn’t guarantee that all messages get delivered. It only guarantees (socket.io broadcast doesn’t guarantee that) that all users see the last message.

Therefore, I’d probably go with a Y.Array as a data structure. However, the content that you put in there will be retained indefinitely, which might not be what you are looking for. So you could remove all entries that are older than X minutes. This really depends on your application.

Thanks @dmonad I don’t need any guarantees, so the current method is working quite well. If the connection drops for some reason and the user misses a log it’s fine.