I wanted to create a shared library to do some communications to an external web server, that I want to use from various apps. I have created a monkey barrel but have not been able to pass a callback function from my main application to the monkeybarrel module, the problem is that there is a callback within the module itself (to handle the asynchronous HTTP repose)
//in my main app:
//call to the 'login function' in my monkeybarrel module
testBarrel.comms.login(URL, uname, pwd, method(:my_callback_function));
// the callback function in my main app to handle the response data from the login
function my_callback_function(data) {
// do stuff with data
}
//and in my tesBarrel.comms module
(:comms)
module comms {
//local vars
var _loginCallback;
function login(URL, uname, pwd, callback) {
// create headers, params and options here...
//as this is inside a module, I had to do this...
var callable = new Lang.Method($, :login_response);
//make the web request
Comms.makeWebRequest(loginURL, params, options, callable);
}
function login_response(responseCode, data) {
// do some processing here
// then invoke the callback function from the main app to pass the result over to it
_loginCallback.invoke(responseCode);
}
}
I can see that the webrequest is sent, but It does not seem like the login_response function ever gets invoked.
When I run the main app I get this:
Error: Symbol Not Found Error
Details: Failed invoking <symbol>
Stack:
Again, it seems like it fires off the web request (can be seen in the HTTP traffic log) but I never see response in the HTTP log, which is odd. Except for the callback function, I use the exact same code Ive used directly fro my app so I know that the web request is good.
If I manage to get the login_response callback to work, I guess I have the next problem with invoking the "original" callback function from the main app...