mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-20 06:29:53 +01:00
Fixed timedelta problem
This commit is contained in:
parent
1faae5b756
commit
e5a22423bb
2 changed files with 30 additions and 17 deletions
|
@ -517,17 +517,15 @@ exports.updatePadClients = function(pad, callback)
|
|||
//go trough all sessions on this pad
|
||||
async.forEach(pad2sessions[pad.id], function(session, callback)
|
||||
{
|
||||
var lastRev = sessioninfos[session].rev;
|
||||
|
||||
//https://github.com/caolan/async#whilst
|
||||
//send them all new changesets
|
||||
async.whilst(
|
||||
function (){ return lastRev < pad.getHeadRevisionNumber()},
|
||||
function (){ return sessioninfos[session].rev < pad.getHeadRevisionNumber()},
|
||||
function(callback)
|
||||
{
|
||||
var author, revChangeset;
|
||||
|
||||
var r = ++lastRev;
|
||||
var author, revChangeset, currentTime;
|
||||
var r = sessioninfos[session].rev + 1;
|
||||
|
||||
async.parallel([
|
||||
function (callback)
|
||||
|
@ -547,6 +545,15 @@ exports.updatePadClients = function(pad, callback)
|
|||
revChangeset = value;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function (callback)
|
||||
{
|
||||
pad.getRevisionDate(r, function(err, date)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
currentTime = date;
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], function(err)
|
||||
{
|
||||
|
@ -564,24 +571,30 @@ exports.updatePadClients = function(pad, callback)
|
|||
else
|
||||
{
|
||||
var forWire = Changeset.prepareForWire(revChangeset, pad.pool);
|
||||
var wireMsg = {"type":"COLLABROOM","data":{type:"NEW_CHANGES", newRev:r,
|
||||
changeset: forWire.translated,
|
||||
apool: forWire.pool,
|
||||
author: author}};
|
||||
var wireMsg = {"type":"COLLABROOM",
|
||||
"data":{type:"NEW_CHANGES",
|
||||
newRev:r,
|
||||
changeset: forWire.translated,
|
||||
apool: forWire.pool,
|
||||
author: author,
|
||||
currentTime: currentTime,
|
||||
timeDelta: currentTime - sessioninfos[session].time
|
||||
}};
|
||||
|
||||
socketio.sockets.sockets[session].json.send(wireMsg);
|
||||
}
|
||||
|
||||
if(sessioninfos[session] != null)
|
||||
{
|
||||
sessioninfos[session].time = currentTime;
|
||||
sessioninfos[session].rev = r;
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
},
|
||||
callback
|
||||
);
|
||||
|
||||
if(sessioninfos[session] != null)
|
||||
{
|
||||
sessioninfos[session].rev = pad.getHeadRevisionNumber();
|
||||
}
|
||||
},callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
|
||||
Changeset.mutateTextLines(changeset, padContents);
|
||||
padContents.currentRevision = revision;
|
||||
padContents.currentTime += timeDelta * 1000;
|
||||
padContents.currentTime += timeDelta;
|
||||
debugLog('Time Delta: ', timeDelta)
|
||||
updateTimer();
|
||||
|
||||
|
|
Loading…
Reference in a new issue