I am trying to implement an APE server side module which hooks the APE 
connect to call a php script and check if the user is logged in on the php 
side. The php script takes a while to run, and I believe on the APE side 
it's not waiting for the asynchronous request to finish. I've tried 
numerous changes to the code, like encapsulating the request in a function 
call but I am at a dead end.

Ape.registerHookCmd("connect", function(params, cmd) {
    Ape.log('custom log');
    if ( ! params || ! params.token) return ["001", "INVALID PARAMS"];
 checkLogin(params, cmd);
});

function checkLogin(params, cmd){
var request = new 
Http('http://dev.itecode.com/bow/auction/index/checkLogin?SID='  + 
params.token+'&proId='+params.proId);
request.getContent(function(result) { //call the PHP file
if ( ! result ) {
//send error if cannot contact page
cmd.sendResponse('ERR', {'code': 1001, 'value': 'error_codes._1001'});
//Ape.log('USER_NOT_LOGGED_IN');
Ape.log(result2.res);
return 0;
}
var result2=JSON.parse(result);
if(result2.res == 'in auction'){
Ape.log(result2.res);
return 1;
}
else {
//send error if not logged in
cmd.sendResponse('ERR', {'code': 1001, 'value': 'error_codes._1001'});
//Ape.log('USER_NOT_LOGGED_IN');
Ape.log(result2.res);
return 0;
}
});
}

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to