mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
Added function to switch to a different pad without having to reload the whole page.
This commit is contained in:
parent
71c7deecd9
commit
4ccd7131d3
4 changed files with 109 additions and 41 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue