Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(awareness): only send updates about the local client
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud authored and backportbot[bot] committed Nov 26, 2024
commit ce033a26057f325eb3af56b87c5f2850fa971789
14 changes: 11 additions & 3 deletions src/services/y-websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ messageHandlers[messageSync] = (
}
}

// modified to only send own awareness
messageHandlers[messageQueryAwareness] = (
encoder,
_decoder,
Expand All @@ -86,7 +87,8 @@ messageHandlers[messageQueryAwareness] = (
encoder,
awarenessProtocol.encodeAwarenessUpdate(
provider.awareness,
Array.from(provider.awareness.getStates().keys()),
[provider.doc.clientID],
// Array.from(provider.awareness.getStates().keys()),
),
)
}
Expand Down Expand Up @@ -377,16 +379,22 @@ export class WebsocketProvider extends Observable {
}
this.doc.on('update', this._updateHandler)
/**
* Send an awareness update message when local awareness changes
* modified to only send update about this client.
* @param {any} changed
* @param {any} _origin
*/
this._awarenessUpdateHandler = ({ added, updated, removed }, _origin) => {
const changedClients = added.concat(updated).concat(removed)
// const changedClients = added.concat(updated).concat(removed)
const encoder = encoding.createEncoder()
encoding.writeVarUint(encoder, messageAwareness)
encoding.writeVarUint8Array(
encoder,
awarenessProtocol.encodeAwarenessUpdate(awareness, changedClients),
awarenessProtocol.encodeAwarenessUpdate(
awareness,
[this.doc.clientID],
// changedClients
),
)
broadcastMessage(this, encoding.toUint8Array(encoder))
}
Expand Down