mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 08:56:17 -04:00
Add in an HTTP API call to send a custom message type.
You cannot currently send any data with your custom message, but this patch is just begging for a second one that will allow that.
This commit is contained in:
parent
aa986ab954
commit
3d4fb81796
3 changed files with 57 additions and 1 deletions
|
@ -512,6 +512,39 @@ exports.listAuthorsOfPad = function(padID, callback)
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
sendClientsMessage(padID, msg) sends a message to all clients connected to the
|
||||
pad, possibly for the purpose of signalling a plugin.
|
||||
|
||||
Note, this will only accept strings from the HTTP API, so sending bogus changes
|
||||
or chat messages will probably not be possible.
|
||||
|
||||
The resulting message will be structured like so:
|
||||
|
||||
{
|
||||
type: 'COLLABROOM',
|
||||
data: {
|
||||
type: <msg>,
|
||||
time: <time the message was sent>
|
||||
}
|
||||
}
|
||||
|
||||
Example returns:
|
||||
|
||||
{code: 0, message:"ok"}
|
||||
{code: 1, message:"padID does not exist"}
|
||||
*/
|
||||
|
||||
exports.sendClientsMessage = function (padID, msg, callback) {
|
||||
getPadSafe(padID, true, function (err, pad) {
|
||||
if (ERR(err, callback)) {
|
||||
return;
|
||||
} else {
|
||||
padMessageHandler.handleCustomMessage(padID, msg, callback);
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
/******************************/
|
||||
/** INTERNAL HELPER FUNCTIONS */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue