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

View File

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