summaryrefslogtreecommitdiff
path: root/src/node/handler
diff options
context:
space:
mode:
authorMike DeRosa <derosm2@gmail.com>2014-06-14 14:24:54 -0400
committerMike DeRosa <derosm2@gmail.com>2014-06-14 14:25:56 -0400
commit4ccd7131d31d931007f0606173bf212fefa30d79 (patch)
tree34a182df21d0930714fd7af214b083d65c673fa6 /src/node/handler
parent71c7deecd98a7444090f0aa544e1c983202cacd2 (diff)
downloadetherpad-lite-4ccd7131d31d931007f0606173bf212fefa30d79.zip
Added function to switch to a different pad without having to reload the whole page.
Diffstat (limited to 'src/node/handler')
-rw-r--r--src/node/handler/PadMessageHandler.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js
index 26eb17a6..fbf43599 100644
--- a/src/node/handler/PadMessageHandler.js
+++ b/src/node/handler/PadMessageHandler.js
@@ -217,6 +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 {
messageLogger.warn("Dropped message, unknown Message Type " + message.type);
}
@@ -872,6 +874,32 @@ function _correctMarkersInPad(atext, apool) {
return builder.toString();
}
+function handleClearSessionInfo(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;
+ var roomClients = socketio.sockets.clients(padId);
+ for(var i = 0; i < roomClients.length; i++) {
+ var sinfo = sessioninfos[roomClients[i].id];
+ if(sinfo && sinfo == currentSession) {
+ // fix user's counter, works on page refresh or if user closes browser window and then rejoins
+ sessioninfos[roomClients[i].id] = {};
+ roomClients[i].leave(padId);
+ }
+ }
+}
+
/**
* Handles a CLIENT_READY. A CLIENT_READY is the first message from the client to the server. The Client sends his token
* and the pad it wants to enter. The Server answers with the inital values (clientVars) of the pad