a safer approach I think but still be careful

This commit is contained in:
John McLear 2013-03-16 13:19:12 +00:00
parent ac9b972358
commit 13ad46aa67
2 changed files with 9 additions and 6 deletions

View File

@ -261,12 +261,13 @@ function handleSaveRevisionMessage(client, message){
* @param sessionID {string} the socketIO session to which we're sending this message
*/
exports.handleCustomObjectMessage = function (msg, sessionID, cb) {
if(sessionID){ // If a sessionID is targeted then send directly to this sessionID
io.sockets.socket(sessionID).emit(msg); // send a targeted message
}else{
socketio.sockets.in(msg.data.padId).json.send(msg); // broadcast to all clients on this pad
if(msg.type === "CUSTOM"){
if(sessionID){ // If a sessionID is targeted then send directly to this sessionID
io.sockets.socket(sessionID).emit(msg); // send a targeted message
}else{
socketio.sockets.in(msg.data.padId).json.send(msg); // broadcast to all clients on this pad
}
}
cb(null, {});
}

View File

@ -278,8 +278,9 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
if (!getSocket()) return;
if (!evt.data) return;
var wrapper = evt;
if (wrapper.type != "COLLABROOM") return;
if (wrapper.type != "COLLABROOM" && wrapper.type != "CUSTOM") return;
var msg = wrapper.data;
if (msg.type == "NEW_CHANGES")
{
var newRev = msg.newRev;
@ -390,6 +391,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
callbacks.onUserLeave(userInfo);
}
}
else if (msg.type == "DISCONNECT_REASON")
{
appLevelDisconnectReason = msg.reason;