Simple question from NaCl newbie ...
In my javascript, I post a message to the NaCl module.
How do I execute a callback in the javascript after this message is handled by the NaCl module?
In the getting-started-tutorial, the following example is given.
function moduleDidLoad() {
HelloTutorialModule = document.getElementById('hello_tutorial');
updateStatus('SUCCESS');
// Send a message to the Native Client module
HelloTutorialModule.postMessage('hello');
}
How do I execute a callback function in HelloTutorialModule.postMessage('hello'); ?
Thanks.
There is no direct way to get a callback that a particular message was received by the NaCl module. You can do it yourself manually, however by passing along an id, and mapping ids to callbacks.
Something like this (untested):
Then in the NaCl module: