mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
Added basic jsdoc for the messages.js file
This commit is contained in:
parent
079126360d
commit
bdfc115a0a
@ -1,6 +1,13 @@
|
||||
var callbacks = {}
|
||||
var callbacks_ids = 1;
|
||||
|
||||
/**
|
||||
* var sendMessage - Sends a message with arguments to the NaCl module
|
||||
*
|
||||
* @param {String} method A named method
|
||||
* @param {(String|Array)} params An array of options or a signle string
|
||||
* @return {void} The NaCl module calls back trought the handleMessage method
|
||||
*/
|
||||
var sendMessage = function(method, params) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var id = callbacks_ids++;
|
||||
@ -14,6 +21,12 @@ var sendMessage = function(method, params) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* handleMessage - Handles messages from the NaCl module
|
||||
*
|
||||
* @param {Object} msg An object given by the NaCl module
|
||||
* @return {void}
|
||||
*/
|
||||
function handleMessage(msg) {
|
||||
if (msg.data.callbackId && callbacks[msg.data.callbackId]) { // if it's a callback, treat it as such
|
||||
callbacks[msg.data.callbackId][msg.data.type](msg.data.ret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user