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:
Mark Holmquist 2012-08-08 10:12:11 -07:00
parent aa986ab954
commit 3d4fb81796
3 changed files with 57 additions and 1 deletions

View file

@ -272,6 +272,28 @@ function handleSaveRevisionMessage(client, message){
});
}
/**
* Handles a custom message (sent via HTTP API request)
*
* @param padID {Pad} the pad to which we're sending this message
* @param msg {String} the message we're sending
*/
exports.handleCustomMessage = function (padID, msg, cb) {
var time = new Date().getTime();
var msg = {
type: 'COLLABROOM',
data: {
type: msg,
time: time
}
};
for (var i in pad2sessions[padID]) {
socketio.sockets.sockets[pad2sessions[padID][i]].json.send(msg);
}
cb(null, {});
}
/**
* Handles a Chat Message
* @param client the client that send this message