Skip to content

Commit 55dcbe4

Browse files
author
Alec Gibson
committed
Use Agent._src getter for presence src
This change updates the Presence `src` field to use the Agent's `_src` getter, which will try to use a client-proposed ID, and then fall back to the server-generated `clientId`. This means that the `src` should be consistent across client reconnections, which helps `RemotePresence` to determine which ops have come from which presence providers.
1 parent 8635b07 commit 55dcbe4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/agent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ Agent.prototype._createPresence = function(request) {
753753
return {
754754
a: 'p',
755755
ch: request.ch,
756-
src: this.clientId,
756+
src: this._src(),
757757
id: request.id, // Presence ID, not Doc ID (which is 'd')
758758
p: request.p,
759759
pv: request.pv,
@@ -801,7 +801,7 @@ Agent.prototype._requestPresence = function(channel, callback) {
801801
};
802802

803803
Agent.prototype._handlePresenceData = function(presence) {
804-
if (presence.src === this.clientId) return;
804+
if (presence.src === this._src()) return;
805805

806806
if (presence.r) return this.send({a: 'pr', ch: presence.ch});
807807

0 commit comments

Comments
 (0)