mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-07 07:37:11 -04:00
amazing offline mode
This commit is contained in:
parent
0a68f06610
commit
8921c1976b
3 changed files with 43 additions and 9 deletions
|
@ -533,7 +533,7 @@ table#otheruserstable { display: none; }
|
|||
margin-bottom: 10px;
|
||||
}
|
||||
#connectionboxinner .disconnected p {
|
||||
margin: 10px 10px;
|
||||
margin: 10px 0;
|
||||
font-size: 1.2em;
|
||||
line-height: 1.1;
|
||||
color: #333;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -203,8 +203,13 @@ function handshake()
|
|||
msg.client_rev=pad.collabClient.getCurrentRevisionNumber();
|
||||
msg.reconnect=true;
|
||||
}
|
||||
|
||||
console.log("sending CLIENT_READY =>");
|
||||
console.log(msg);
|
||||
socket.json.send(msg);
|
||||
if(isReconnect == true)
|
||||
{
|
||||
pad.collabClient.processDisconnectedMessages();
|
||||
}
|
||||
};
|
||||
|
||||
var disconnectTimeout;
|
||||
|
@ -219,9 +224,8 @@ function handshake()
|
|||
{
|
||||
clearTimeout(disconnectTimeout);
|
||||
}
|
||||
|
||||
pad.collabClient.setChannelState("CONNECTED");
|
||||
sendClientReady(true);
|
||||
pad.collabClient.setChannelState("CONNECTED");
|
||||
});
|
||||
|
||||
socket.on('disconnect', function (reason) {
|
||||
|
@ -703,10 +707,10 @@ var pad = {
|
|||
{
|
||||
padconnectionstatus.reconnecting();
|
||||
|
||||
padeditor.disable();
|
||||
/*padeditor.disable();
|
||||
padeditbar.disable();
|
||||
paddocbar.disable();
|
||||
padimpexp.disable();
|
||||
padimpexp.disable();*/
|
||||
}
|
||||
else if (newState == "DISCONNECTED")
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue