Where is your "return -2" ???

It's not complicated, the template is :

Ape.registerhookCmd("CONNECT", function(params, cmd) {
        Ape.MySQL.query('query', function(res, errno) { /* Async call (after
return -2) */
                cmd.user.setProperty('whatever', res[0].whatever);
                Ape.addUser(cmd.user); /* Confirm the connection => LOGIN+IDENT 
RAW with
custom properties */
        });

        return -2; /* Delay the connection (make the client hanging) */
});

Just like the http_auth.js template (the http callback is async just like
the MySQL callback)

On Sun, 18 Jul 2010 07:15:38 -0700 (PDT), hlop <[email protected]> wrote:
> i do it so:
> 
> Ape.registerHookCmd("connect", function(params, cmd) {
>       sql_query(cmd, params, function(result) {
>               if (result == 1) Ape.addUser(cmd.user);
>               else cmd.user.setProperty('name', result);
>       });
> 
>       cmd.user.setProperty('uid', params.uid);
> 
>       return 1;
> });
> 
> function sql_query(cmd, params,callback){
>       sql.query('SELECT * FROM user WHERE uid="'+params.uid+'" LIMIT 1;',
> function(res, errorNo) {
>               if (errorNo) {
>                       username = "mysql error";
>               } else {
>                       username = (res[0].name.length>=3 ? res[0].name :
> (res[0].id>0?"USER "+res[0].id:"Guest") );
>                       cmd.user.setProperty('name', username);
>                       callback(1);
>               }
> 
>               var ret = {};
>               try { ret = username; } catch(e){};
> 
>               callback(ret);
>               //Ape.addUser(cmd.user);
>       });
> }
> 
> 
> 
> but it don't work correctly, can you help me more?

-- 
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