Add comments to some of the code I touched/created.
This commit is contained in:
parent
948de2bdbe
commit
fcd612e486
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper for data to facilitate adding functionality to messages.
|
||||||
|
*/
|
||||||
function Message(data) {
|
function Message(data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.allowsReply = false;
|
this.allowsReply = false;
|
||||||
@ -10,6 +13,9 @@ function Message(data) {
|
|||||||
this.id;
|
this.id;
|
||||||
}
|
}
|
||||||
Message.prototype = {
|
Message.prototype = {
|
||||||
|
/**
|
||||||
|
* Reply to the action handler that sent the message.
|
||||||
|
*/
|
||||||
reply: function messageReply(data) {
|
reply: function messageReply(data) {
|
||||||
if (!this.allowsReply)
|
if (!this.allowsReply)
|
||||||
error('This message does not accept replies.');
|
error('This message does not accept replies.');
|
||||||
@ -20,6 +26,11 @@ Message.prototype = {
|
|||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Setup the message to allow a reply.
|
||||||
|
* @param {function} messager A function that takes a JSON reply.
|
||||||
|
* @param {String} id The id to identify this message.
|
||||||
|
*/
|
||||||
setupReply: function setupReply(messager, id) {
|
setupReply: function setupReply(messager, id) {
|
||||||
this.allowsReply = true;
|
this.allowsReply = true;
|
||||||
this.messager = messager;
|
this.messager = messager;
|
||||||
@ -73,7 +84,12 @@ MessageHandler.prototype = {
|
|||||||
}
|
}
|
||||||
ah[actionName] = [handler, scope];
|
ah[actionName] = [handler, scope];
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Sends a message to the comObj to invoke the action with the supplied data.
|
||||||
|
* @param {String} actionName Action to call.
|
||||||
|
* @param {JSON} data JSON data to send.
|
||||||
|
* @param {function} [callback] Optional callback that will handle a reply.
|
||||||
|
*/
|
||||||
send: function messageHandlerSend(actionName, data, callback) {
|
send: function messageHandlerSend(actionName, data, callback) {
|
||||||
var message = {
|
var message = {
|
||||||
action: actionName,
|
action: actionName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user