Well,

Let me show you this code, I got 2 version one using class and this
one , extraneously enough this and the class works fine in my vmware
test bed, the user properties gets set once the client land in the
page, but in my production server and same code, either the class or
the regular one fails to set properties on landing..

 I have to reload the page to see the properties been set in
this.core.user.properties , I guess because my production server is
live there is access to Mysql from other scripts..

see the code, this one not being a class.

var userlist = new $H;
var sql      = MySQLConnectMySQLConnect('127.0.0.1', 'user',
'password', 'Ape_users')
Ape.registerHookCmd("connect", function(params, cmd) {
        if (!$defined(params) || !$defined(params.name)) return 0;
        if (userlist.has(params.name.toLowerCase())) return ["007",
"NICK_USED"];
        //if (params.name.length > 16 || params.name.test('[^a-zA-Z0-9]',
'i')) return ["006", "BAD_NICK"];


        cmd.user.setProperty('name', params.name);
        cmd.user.setProperty('ip', cmd.ip);
        setloggedinProperties(cmd.user);
        return 1;
});

Ape.addEvent('adduser', function(user) {
        userlist.set(user.getProperty('name').toLowerCase(), true);
});

Ape.addEvent('deluser', function(user) {
        userlist.erase(user.getProperty('name').toLowerCase());
});
function setloggedinProperties(user){

    var usernick = user.getProperty('name').toLowerCase();
        sql.query('SELECT * FROM pfc_login WHERE BINARY
username="'+Ape.MySQL.escape(usernick)+'"',function(res,error){
                if(error){
                        Ape.log('There was an error in the query 
'+this.errorString()+'');
                        }else{
                        var isauthorized;
                        if(res != ''){
                                isauthorized   = res[0].isauthorized;
                        }
                        if (isauthorized)user.setProperty('isauthorized', 
isauthorized);
                }
        });


}

    function MySQLConnect(ip, user, password, database) {
        var sql = new Ape.MySQL(ip + ":3306", user, password,
database);

        //onConnect callback
        sql.onConnect = function() {
            Ape.log('You are now connected to MySQL server');
        }

        //onError callback
        sql.onError = function(errorNo) {
            Ape.log('Connection error ' + errorNo +' '+
this.errorString());
        }

        return sql;
    }

        //Set up a poller to send keep alive request each 2 minutes
                        (function() {
                                sql.query('SELECT 1', function(res, errorNo) {
                                        if (errorNo == 8) { //Something went 
wrong, connection has been
closed
                                                Ape.log('Something went wrong, 
connection has been closed');
                                                sql = 
MySQLConnectMySQLConnect('127.0.0.1', 'user', 'password',
'Ape_users'); //Reconnect to MySQL Server
                                        }
                                }.bind(this));
                        }).periodical(1000*60*2);

if (isauthorized)user.setProperty('isauthorized', isauthorized); get
sets but too late user has landed in the page without that properties
but in the background is set but you need to reload the page to see
the new setting take effects..

One fix I could think of is sending a sendRaw to the channel updating
manually but that seems redundant and dont like it...

Can anyone suggest something..

How can I stop the chain reaction until the user properties are set
correctly.. how are you guys are doing this..

My application its hooked to my login system.. there is a guest
feature so people can login as guest.. so my script checks for is
authorized to user nicks that are registered..

I am starting to think that this can be done and to find a better way
to do it using inline push but I just want to find out if somebody
fixed this predicament.. until version 2 is done, because I read in
the wiki that the new version when setting user properties this will
be fired automatically in the client instead of use using a raw after
setting this properties..

kind regards..

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