Fix few mistakes

This commit is contained in:
anugu-chegg 2018-02-16 01:31:47 +05:30 committed by muxator
parent d41e184a3c
commit 461ed413b7
2 changed files with 37 additions and 24 deletions

View File

@ -1226,8 +1226,8 @@ function handleClientReady(client, message)
var forWire = Changeset.prepareForWire(changesets[r], pad.pool);
var wireMsg = {"type":"COLLABROOM",
"data":{type:"CLIENT_RECONNECT",
currRev: r,
newRev:pad.getHeadRevisionNumber(),
headRev:pad.getHeadRevisionNumber(),
newRev:r,
changeset:forWire.translated,
apool: forWire.pool,
author: changesetsAuthor[r],
@ -1243,8 +1243,6 @@ function handleClientReady(client, message)
noChanges: true,
newRev:pad.getHeadRevisionNumber()
}};
console.log("About to send client reconnect event");
client.json.send(Msg);
}
});

View File

@ -349,38 +349,53 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
return;
}
var currRev = msg.currRev;
var headRev = msg.headRev;
var newRev = msg.newRev;
var changeset = msg.changeset;
var author = (msg.author || '');
var apool = msg.apool;
if (rev + 1 == currRev)
if (msgQueue.length > 0)
{
if (author == pad.getUserId())
if (newRev != (msgQueue[msgQueue.length - 1].newRev + 1))
{
editor.applyPreparedChangesetToBase();
setStateIdle();
callCatchingErrors("onInternalAction", function()
{
callbacks.onInternalAction("commitAcceptedByServer");
});
callCatchingErrors("onConnectionTrouble", function()
{
callbacks.onConnectionTrouble("OK");
});
handleUserChanges();
}
else
{
editor.applyChangesToBase(changeset, author, apool);
window.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1));
// setChannelState("DISCONNECTED", "badmessage_acceptcommit");
return;
}
msg.type = "NEW_CHANGES";
msgQueue.push(msg);
return;
}
if (rev + 1 < currRev)
if (newRev != (rev + 1))
{
window.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1));
// setChannelState("DISCONNECTED", "badmessage_acceptcommit");
return;
}
rev = newRev;
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 (currRev == newRev)
if (newRev == headRev)
{
rev = newRev;
socketIOError = false;