summaryrefslogtreecommitdiff
path: root/src/node/handler/PadMessageHandler.js
diff options
context:
space:
mode:
authorMike DeRosa <derosm2@gmail.com>2014-07-12 16:27:00 -0400
committerMike DeRosa <derosm2@gmail.com>2014-07-12 16:27:00 -0400
commit7861cae76325c4fbc07876d95a264310a5bdc574 (patch)
tree46b75ce36538fdb463ab0fd8fbc12135f38b172a /src/node/handler/PadMessageHandler.js
parent070ba40f4f7c64f1ed14df13749f94b59b9ce961 (diff)
downloadetherpad-lite-7861cae76325c4fbc07876d95a264310a5bdc574.zip
Cleaning up switchToPad functionality so that we only need one call to the server("SWITCH_TO_PAD") instead of two (cleaning session info and client ready).
Also Clearing chat messages when switchToPad is called in pad.js instead of having the server tell the client to clear the chat messages.
Diffstat (limited to 'src/node/handler/PadMessageHandler.js')
-rw-r--r--src/node/handler/PadMessageHandler.js49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js
index fbf43599..d0184bc2 100644
--- a/src/node/handler/PadMessageHandler.js
+++ b/src/node/handler/PadMessageHandler.js
@@ -217,8 +217,8 @@ exports.handleMessage = function(client, message)
} else {
messageLogger.warn("Dropped message, unknown COLLABROOM Data Type " + message.data.type);
}
- } else if(message.type == "CLEAR_SESSION_INFO") {
- handleClearSessionInfo(client, message);
+ } else if(message.type == "SWITCH_TO_PAD") {
+ handleSwitchToPad(client, message);
} else {
messageLogger.warn("Dropped message, unknown Message Type " + message.type);
}
@@ -232,18 +232,7 @@ exports.handleMessage = function(client, message)
{
// client tried to auth for the first time (first msg from the client)
if(message.type == "CLIENT_READY") {
- // Remember this information since we won't
- // have the cookie in further socket.io messages.
- // This information will be used to check if
- // the sessionId of this connection is still valid
- // since it could have been deleted by the API.
- sessioninfos[client.id].auth =
- {
- sessionID: message.sessionID,
- padID: message.padId,
- token : message.token,
- password: message.password
- };
+ createSessionInfo(client, message);
}
// Note: message.sessionID is an entirely different kind of
@@ -874,18 +863,8 @@ function _correctMarkersInPad(atext, apool) {
return builder.toString();
}
-function handleClearSessionInfo(client, message)
+function handleSwitchToPad(client, message)
{
- var infoMsg = {
- type: "COLLABROOM",
- data: {
- type: "CLEAR_CHAT_MESSAGES"
- }
- };
-
- // send the messages back to the client to clear the chat messages
- client.json.send(infoMsg);
-
// clear the session and leave the room
var currentSession = sessioninfos[client.id];
var padId = currentSession.padId;
@@ -898,6 +877,26 @@ function handleClearSessionInfo(client, message)
roomClients[i].leave(padId);
}
}
+
+ // start up the new pad
+ createSessionInfo(client, message);
+ handleClientReady(client, message);
+}
+
+function createSessionInfo(client, message)
+{
+ // Remember this information since we won't
+ // have the cookie in further socket.io messages.
+ // This information will be used to check if
+ // the sessionId of this connection is still valid
+ // since it could have been deleted by the API.
+ sessioninfos[client.id].auth =
+ {
+ sessionID: message.sessionID,
+ padID: message.padId,
+ token : message.token,
+ password: message.password
+ };
}
/**