Send commits missed during the reconnect
parent
bf05e9ae89
commit
d41e184a3c
|
@ -1177,33 +1177,51 @@ function handleClientReady(client, message)
|
|||
{
|
||||
changesetsNeeded.push(r);
|
||||
}
|
||||
//get all changesets
|
||||
async.forEach(changesetsNeeded, function(revNum)
|
||||
callback();
|
||||
},
|
||||
//get all changesets
|
||||
function(callback)
|
||||
{
|
||||
async.eachSeries(changesetsNeeded, function(revNum, callback)
|
||||
{
|
||||
pad.getRevisionChangeset(revNum, function(err, value)
|
||||
{
|
||||
if(ERR(err)) return;
|
||||
changesets[revNum] = value;
|
||||
callback();
|
||||
});
|
||||
}, callback);
|
||||
},
|
||||
function(callback)
|
||||
{
|
||||
async.eachSeries(changesetsNeeded, function(revNum, callback)
|
||||
{
|
||||
pad.getRevisionAuthor(revNum, function(err, value)
|
||||
{
|
||||
if(ERR(err)) return;
|
||||
changesetsAuthor[revNum] = value;
|
||||
callback();
|
||||
});
|
||||
}, callback);
|
||||
},
|
||||
function(callback)
|
||||
{
|
||||
async.eachSeries(changesetsNeeded, function(revNum, callback)
|
||||
{
|
||||
pad.getRevisionDate(revNum, function(err, value)
|
||||
{
|
||||
if(ERR(err)) return;
|
||||
changesetsTimestamp[revNum] = value;
|
||||
callback();
|
||||
});
|
||||
});
|
||||
callback(null);
|
||||
}, callback);
|
||||
}
|
||||
],
|
||||
//return err and changeset
|
||||
function(err)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
async.eachSeries(changesetsNeeded, function(r)
|
||||
async.eachSeries(changesetsNeeded, function(r, callback)
|
||||
{
|
||||
var forWire = Changeset.prepareForWire(changesets[r], pad.pool);
|
||||
var wireMsg = {"type":"COLLABROOM",
|
||||
|
@ -1216,7 +1234,8 @@ function handleClientReady(client, message)
|
|||
currentTime: changesetsTimestamp[r]
|
||||
}};
|
||||
client.json.send(wireMsg);
|
||||
});
|
||||
callback();
|
||||
});
|
||||
if (startNum == endNum)
|
||||
{
|
||||
var Msg = {"type":"COLLABROOM",
|
||||
|
|
|
@ -342,6 +342,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
}
|
||||
else if (msg.type == 'CLIENT_RECONNECT')
|
||||
{
|
||||
// When client has reconnected but there are no pending changes from other clients
|
||||
if (msg.noChanges)
|
||||
{
|
||||
socketIOError = false;
|
||||
|
@ -354,19 +355,26 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
var author = (msg.author || '');
|
||||
var apool = msg.apool;
|
||||
|
||||
|
||||
if (rev + 1 == currRev)
|
||||
{
|
||||
if (author == pad.getUserId())
|
||||
{
|
||||
editor.applyPreparedChangesetToBase();
|
||||
setStateIdle();
|
||||
callCatchingErrors("onInternalAction", function()
|
||||
{
|
||||
callbacks.onInternalAction("commitAcceptedByServer");
|
||||
});
|
||||
callCatchingErrors("onConnectionTrouble", function()
|
||||
{
|
||||
callbacks.onConnectionTrouble("OK");
|
||||
});
|
||||
handleUserChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
editor.applyChangesToBase(changeset, author, apool);
|
||||
}
|
||||
|
||||
}
|
||||
if (rev + 1 < currRev)
|
||||
{
|
||||
|
@ -374,8 +382,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
}
|
||||
if (currRev == newRev)
|
||||
{
|
||||
socketIOError = false;
|
||||
rev = newRev;
|
||||
socketIOError = false;
|
||||
}
|
||||
}
|
||||
else if (msg.type == "NO_COMMIT_PENDING")
|
||||
|
|
Loading…
Reference in New Issue