hey all ! i am a bit confused about the change event listener in y-protocols/awareness . it listen both remote and local change on awareness… i checked the sourceCode of y-websocket here: https://github.com/yjs/y-websocket/blob/master/src/y-websocket.js, the awareness code is as below:
this._awarenessUpdateHandler = ({ added, updated, removed }, origin) => { // why not tell origin here
const changedClients = added.concat(updated).concat(removed)
const encoder = encoding.createEncoder()
encoding.writeVarUint(encoder, messageAwareness)
encoding.writeVarUint8Array(encoder, awarenessProtocol.encodeAwarenessUpdate(awareness, changedClients))
broadcastMessage(this, encoding.toUint8Array(encoder)) // if comes from remote, why broadcast out, will lead to endless loop or not ...
}
awareness.on('change', this._awarenessUpdateHandler) // both remote and local change
if received change from remote origin, it broadcast the change message back to server, will that lead to endless loop ?