mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-08 16:05:05 -04:00
amazing offline mode
This commit is contained in:
parent
0a68f06610
commit
8921c1976b
3 changed files with 43 additions and 9 deletions
|
@ -277,9 +277,38 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
setChannelState("CONNECTED");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var disconnectedMessages = [];
|
||||
|
||||
function processDisconnectedMessages()
|
||||
{
|
||||
//assume that it is connected
|
||||
var len = disconnectedMessages.length;
|
||||
while(disconnectedMessages.length)
|
||||
{
|
||||
var msg = disconnectedMessages.shift();//remove from the array
|
||||
_sendMessage(msg);//process.
|
||||
}
|
||||
}
|
||||
|
||||
function sendMessage(msg)
|
||||
{
|
||||
|
||||
if(channelState != "CONNECTED")
|
||||
{
|
||||
console.log("Channel is not connected WAITING");
|
||||
disconnectedMessages.push(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
_sendMessage(msg);
|
||||
}
|
||||
|
||||
function _sendMessage(msg)
|
||||
{
|
||||
console.log("sending msg =>");
|
||||
console.log(msg);
|
||||
|
||||
getSocket().json.send(
|
||||
{
|
||||
type: "COLLABROOM",
|
||||
|
@ -287,7 +316,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
data: msg
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function wrapRecordingErrors(catcher, func)
|
||||
{
|
||||
return function()
|
||||
|
@ -671,7 +700,8 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
getMissedChanges: getMissedChanges,
|
||||
callWhenNotCommitting: callWhenNotCommitting,
|
||||
addHistoricalAuthors: tellAceAboutHistoricalAuthors,
|
||||
setChannelState: setChannelState
|
||||
setChannelState: setChannelState,
|
||||
processDisconnectedMessages: processDisconnectedMessages
|
||||
};
|
||||
|
||||
$(document).ready(setUpSocket);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue