diff options
author | Richard Braakman <richard.braakman@jollamobile.com> | 2012-09-27 23:05:18 +0300 |
---|---|---|
committer | Richard Braakman <richard.braakman@jollamobile.com> | 2012-09-27 23:07:00 +0300 |
commit | 7aaef01346ca61d7778c15f9b35f72713065f297 (patch) | |
tree | c7d37bbc29a37f801f1ca56ac103c360cf7b1601 /src/node/handler | |
parent | f1b4206cadb716dd3c4b2c924e0b988431034263 (diff) | |
download | etherpad-lite-7aaef01346ca61d7778c15f9b35f72713065f297.zip |
Prettify session handling in handleUserChanges
Also add a comment to explain what's going on with thisSession.
No changes in behavior.
Diffstat (limited to 'src/node/handler')
-rw-r--r-- | src/node/handler/PadMessageHandler.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 6a462b01..8a5a92bb 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -465,7 +465,9 @@ function handleUserChanges(client, message) var baseRev = message.data.baseRev; var wireApool = (new AttributePool()).fromJsonable(message.data.apool); var changeset = message.data.changeset; - var thisAuthor = sessioninfos[client.id].author; + // The client might disconnect between our callbacks. We should still + // finish processing the changeset, so keep a reference to the session. + var thisSession = sessioninfos[client.id]; var r, apool, pad; @@ -473,7 +475,7 @@ function handleUserChanges(client, message) //get the pad function(callback) { - padManager.getPad(sessioninfos[client.id].padId, function(err, value) + padManager.getPad(thisSession.padId, function(err, value) { if(ERR(err, callback)) return; pad = value; @@ -550,7 +552,7 @@ function handleUserChanges(client, message) return; } - pad.appendRevision(changeset, thisAuthor); + pad.appendRevision(changeset, thisSession.author); var correctionChangeset = _correctMarkersInPad(pad.atext, pad.pool); if (correctionChangeset) { |