reverted offlinemode. It works but is hackish. Will try a better a cleaner approach. Removed tons a commented code

This commit is contained in:
Jean-Tiare Le Bigot 2012-03-04 12:02:39 +01:00
parent 8921c1976b
commit 36d640d929
2 changed files with 8 additions and 89 deletions

View file

@ -189,71 +189,11 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
function setUpSocket()
{
//oldSocketId = String(Math.floor(Math.random()*1e12));
//socketId = String(Math.floor(Math.random()*1e12));
/*socket = new io.Socket();
socket.connect();*/
//socket.on('connect', function(){
hiccupCount = 0;
setChannelState("CONNECTED");
/*var msg = { type:"CLIENT_READY", roomType:'padpage',
roomName:'padpage/'+globalPadId,
data: {
lastRev:rev,
userInfo:userSet[userId],
stats: getStats() } };
if (oldSocketId) {
msg.data.isReconnectOf = oldSocketId;
msg.data.isCommitPending = (state == "COMMITTING");
}
sendMessage(msg);*/
doDeferredActions();
initialStartConnectTime = +new Date();
// });
/*socket.on('message', function(obj){
if(window.console)
console.log(obj);
handleMessageFromServer(obj);
});*/
/*var success = false;
callCatchingErrors("setUpSocket", function() {
appLevelDisconnectReason = null;
var oldSocketId = socketId;
socketId = String(Math.floor(Math.random()*1e12));
socket = new WebSocket(socketId);
socket.onmessage = wrapRecordingErrors("socket.onmessage", handleMessageFromServer);
socket.onclosed = wrapRecordingErrors("socket.onclosed", handleSocketClosed);
socket.onopen = wrapRecordingErrors("socket.onopen", function() {
hiccupCount = 0;
setChannelState("CONNECTED");
var msg = { type:"CLIENT_READY", roomType:'padpage',
roomName:'padpage/'+globalPadId,
data: {
lastRev:rev,
userInfo:userSet[userId],
stats: getStats() } };
if (oldSocketId) {
msg.data.isReconnectOf = oldSocketId;
msg.data.isCommitPending = (state == "COMMITTING");
}
sendMessage(msg);
doDeferredActions();
});
socket.onhiccup = wrapRecordingErrors("socket.onhiccup", handleCometHiccup);
socket.onlogmessage = dmesg;
socket.connect();
success = true;
});
if (success) {
initialStartConnectTime = +new Date();
}
else {
abandonConnection("initsocketfail");
}*/
}
var hiccupCount = 0;
@ -278,30 +218,14 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
}
}
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")
getSocket().json.send(
{
console.log("Channel is not connected WAITING");
disconnectedMessages.push(msg);
return;
}
_sendMessage(msg);
type: "COLLABROOM",
component: "pad",
data: msg
});
}
function _sendMessage(msg)
@ -700,8 +624,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
getMissedChanges: getMissedChanges,
callWhenNotCommitting: callWhenNotCommitting,
addHistoricalAuthors: tellAceAboutHistoricalAuthors,
setChannelState: setChannelState,
processDisconnectedMessages: processDisconnectedMessages
setChannelState: setChannelState
};
$(document).ready(setUpSocket);

View file

@ -206,10 +206,6 @@ function handshake()
console.log("sending CLIENT_READY =>");
console.log(msg);
socket.json.send(msg);
if(isReconnect == true)
{
pad.collabClient.processDisconnectedMessages();
}
};
var disconnectTimeout;
@ -707,10 +703,10 @@ var pad = {
{
padconnectionstatus.reconnecting();
/*padeditor.disable();
padeditor.disable();
padeditbar.disable();
paddocbar.disable();
padimpexp.disable();*/
padimpexp.disable();
}
else if (newState == "DISCONNECTED")
{