Hey guys,
This a typical scenario in JS, you must call your function in the callback. In the case of APE if you need to get the data back to the user then in your function/callback you must sent a raw to the user pipe, like Mike suggested. The response to the user does not needs to originate from the original request.
--
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to ape-p...@googlegroups.com
To unsubscribe from this group, send email to
ape-project...@googlegroups.com
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/
---
You received this message because you are subscribed to the Google Groups "APE Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ape-project...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dear Pablo!
I don't want to be irksome, but I still don't understand, and I feel, I composed my question badly. So I did a snipet to represent my real problem:
Ape.registerCmd('somecommand', false, function(params, infos) {
var channel = Ape.getChannelByPubid(params.pipe);
...
sql.query("SELECT * FROM table", function(res, errorNo) {
//Here I get the res, which contains all the mysql returned data
});
...
//And than I wnat to work with the res outside the sql, so here:
if(res[0].someparam == 1){
//Some bussines logic with sql queries and other stuff
}
else{
//Some other bussines logic with sql queries and other stuff
}
...
if(channel){
//And use here in the returning data
channel.pipe.sendRaw('response',{'sqldata':res[0].somedata});
}
else{
return ['109', 'UNKNOWN_PIPE'];
}
return 1;
});
How can I do this?
Thank you for your attention!
Hey,
Sorry for the formatting, change your sample in my mobile. Try something like this:
Ape.registerCmd('somecommand', false, function(params, infos) {
var channel = Ape.getChannelByPubid(params.pipe);
...
sql.query("SELECT * FROM table", function(res, errorNo) {
//And than I wnat to work with the res outside the sql, so here:
if(res[0].someparam == 1){
//Some bussines logic with sql queries and other stuff
}
else{
//Some other bussines logic with sql queries and other stuff
}
...
if(channel){
//And use here in the returning data
channel.pipe.sendRaw('response',{'sqldata':res[0].somedata});
}
});
return 1;
});