mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
new function for handling custom messages, allows objects to be sent, before we only allowed strings
This commit is contained in:
parent
0717ac7b88
commit
83a820b720
1 changed files with 17 additions and 0 deletions
|
@ -254,6 +254,23 @@ function handleSaveRevisionMessage(client, message){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a custom message, different to the function below as it handles objects not strings and you can direct the message to specific sessionID
|
||||||
|
*
|
||||||
|
* @param msg {Object} the message we're sending
|
||||||
|
* @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
|
||||||
|
}
|
||||||
|
|
||||||
|
cb(null, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a custom message (sent via HTTP API request)
|
* Handles a custom message (sent via HTTP API request)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue