diff options
author | Mark Holmquist <mtraceur@member.fsf.org> | 2012-08-08 10:12:11 -0700 |
---|---|---|
committer | Mark Holmquist <mtraceur@member.fsf.org> | 2012-08-08 10:12:11 -0700 |
commit | 3d4fb8179689c581e6f01c626d7d364a9e7d43b7 (patch) | |
tree | 549ef9e1b2d9278f3e0da0c8817082faa75f41ee /src/node/db | |
parent | aa986ab9544f01d0ac1611b97ab8be73c32c5992 (diff) | |
download | etherpad-lite-3d4fb8179689c581e6f01c626d7d364a9e7d43b7.zip |
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.
Diffstat (limited to 'src/node/db')
-rw-r--r-- | src/node/db/API.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/node/db/API.js b/src/node/db/API.js index 4a1371ba..64ddef68 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -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 */ |