Hi everyone and thank you for reading my message,

I'm using APE server with my website (Apache), everything works fine
so far.

I'm really pleased to see how quick the call`s to the server are !

I have set up a timer on my website so every few seconds the client is
sending a message to the APE Server to get back the real time which is
stored in my database. The client update the timer on the page.


What I don`t understand is what I get on firebug, before each call to
the server, I get this


POST http://2.ape.my.domain.fr:6969/0/? 200 OK 939ms
[{"time":"1285609854","raw":"CLOSE","data":{"value":"null"}}]

and then

POST http://2.ape.youcent.fr:6969/0/? 200 OK 69ms
[{"time":"1285609853","raw":"info","data":{"enchere":
[{"id":"3","min":"29","sec":"0","last":"trae"}],"chl":5}}]

What is it the « close » message ? Is that normal ? how can I improve
my system ?
Could check my work and tell me if something wrong ?

Here`s what I've done :

My client side :

$(document).ready(function(){
     var client = new APE.Client();

     //Load APE client

     client.load();

     client.addEvent('load', function() {
          client.core.start({'name': '' + Date.now() + ''});//Start
with a random name
      });

     client.addEvent('ready', function() {
         // call every seconds

          $.timer(1000, function (timer) {
               client.core.request.send( 'my_fonction_ape' );//send
getInfo command
          });

          //onRaw info callback
         client.onRaw('info', function( raw, params ) {
               $.each( raw.data.enchere, function(i,o){
                      // traitement
               });
         });
     });
});



Here`s what I have on the server side :

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

//connect to MySQL Server
/**
* /!\ You must specify a user and password, mysql module does not
support yet connecting with a user without password. /!\
*/

var sql = MySQLConnect("127.0.0.1", "root", "root",
"my_database_name");

//Set up a pooller to send keep alive request each 2minutes
(function() {
         sql.query('SELECT 1', function(res, errorNo) {
              if (errorNo == 8) {//Something went wrong, connection
has been closed
              sql = MySQLConnect("127.0.0.1", "root", "root",
"my_database_name"); //Reconnect to MySQL Server
        }
}.bind(this));
}).periodical(1000*60*2);

/*
* Register getInfo command
*/

Ape.registerCmd('my_fonction_ape', true, function(params, cmd) {
        var my_sql = 'SELECT id, EXTRACT( MINUTE FROM abr_timer ) as
min, EXTRACT( SECOND FROM
                              abr_timer ) as sec, '+
                              'last_bidder, price '+
                              'FROM name_abr '+
                              'WHERE abr_etat = "2" ';

//Get data from mysql table
sql.query( my_sql, function(res, errorNo) {
           if (errorNo) {
                    Ape.log('Request error : ' + errorNo + ' : '+
this.errorString());
           return ['101', 'MYSQL_ERROR'];
}else{
            Ape.log('Fetching ' + res.length + ' result(s)');//Display
to logs data received from mysql
           cmd.sendResponse('info', {'enchere' : res } );//Send
results to client
}

});

})



This is probably pretty obvious to you, but not for me.

Any help appreciated.

Thx in advance.














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