[APE-Project] Two question on this server.

46 views
Skip to first unread message

Auryn

unread,
May 6, 2012, 4:25:06 PM5/6/12
to APE Project
Hi everybody ! =D

I've an APE Server for my MMO Project.

I've two question on that :
- If two APE users (or more) send a request on APE which send a raw at
all users, the server send the two (or more) raw in one ajax request
or in two ajax request ? :o
- I'm trying to uptdate the positions of my users directly on APE, and
save the positions in a MySQL Base by a HTTP Request (because MySQL
don't work, i don't know why... :/), only when the user leave the APE
Server. (Before his destruction.) How can I do ? :o

Sorry for my bad english, I'm french and I hope that anyone can help
me. =D

Thanks a lot ! :)

Louis Charette

unread,
May 7, 2012, 5:25:08 PM5/7/12
to ape-p...@googlegroups.com
Salut,

Pour la 1ère question, je ne suis pas sûr à 100%, mais je dirait que deux "requêtes" sont envoyé. Mais je met requête entre guillemets parce que, côté APE, ça ne changera pas grand chose niveau bande passante/ressources. Je ne suis pas un expert dans cet aspect de APE.

Pour la 2e question, tu peux regarder cette page pour le event "deluser" ou peut-être "left": 

Le fait que MySQL ne fonctionne pas est un problème connus. Fait une recherche sur le groupe google, tu trouveras peut-être réponse à ta question. De mon côté, je trouve ça plus facile de faire des requêtes HTTP ou AJAX côté client. Je peux alors utiliser mon framework PHP déjà en place.

----

Hi,

For the first question, I'm not sure, but I would say two "request". Still, "request" may not be exact, I'm not an expert in this side of APE, but there won't be any difference regarding brandwidth and/or ressources.

For the second question, have a look at the "deluser" and "left" event in the doc:

MySQL support is a know bug. You can check this google group, you might find an answer. Still, I prefer using HTTP requests or AJAX request client side. Then I can use the framework and settings of my CMS.



    - Louis


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

a.c...@weelya.com

unread,
May 7, 2012, 5:29:41 PM5/7/12
to ape-p...@googlegroups.com

Hi,

The server pack all "raw" every 50ms. So if 2 raws are sent within this delay, they are packed in one request.
Also you can achieve the same effect on the client-send-side by enabling the "cycledStack". If a client are sending 2 command within a defined period, all the requests are packed in a single commands array.

See : http://www.ape-project.org/docs/client/core/request.cycledstack.add.html

Thanks,

Anthony

Nicolas Guibert

unread,
May 7, 2012, 5:34:35 PM5/7/12
to ape-p...@googlegroups.com
Hi Anthony,

Great to see you back here!

Nicolas.

Auryn

unread,
May 8, 2012, 4:34:09 AM5/8/12
to APE Project
Hi,
Thanks all for your response.

For the first, so it's okay now. ^^

For the second, I'm going to try the deluser's event and I come back
to you if I've any problem.
Just a question :
When the event "deluser" is fired ? :o
If I've my Application on a html page and I leave my navigator, I'm
deconnected ? :o

Thanks.

Nicolas Guibert

unread,
May 8, 2012, 5:34:36 AM5/8/12
to ape-p...@googlegroups.com
In the default case (long polling), the browser closes the open request to the APE server every 25 seconds and reopens a new one. You should be able to see this in Firebug or any console (network tab) log. If you leave the browser or go to another page, this will end and after 45 seconds without news the APE server will delete the user.

I hope this helps.

Nicolas.

2012/5/8 Auryn <arcanes-...@hotmail.fr>

Auryn

unread,
May 8, 2012, 7:44:39 AM5/8/12
to APE Project
So if I don't leave my navigator and I don't send a request, my user
on APE would be destroy ? :o

Else, I've an other problem :
Sometimes APE give me an error "BAD_CHL".
I don't know why ?


Thanks.

a.c...@weelya.com

unread,
May 8, 2012, 7:47:10 AM5/8/12
to ape-p...@googlegroups.com

Indeed, the server cleans up every ghost connections (timeout). So that if one of your user shutdown his browser, APE automatically removes it after 45sec.

BAD_CHL has been fixed. You should try to update using the last Git master.

Anthony

Auryn

unread,
May 8, 2012, 12:38:44 PM5/8/12
to APE Project
Yes but my Webhost was really busied this times.

Can I fixe this bug without the Git master ?
Because on my PC it work good and I've sometimes this error, but on my
IPod, I've always this error... :/
Message has been deleted

Auryn

unread,
May 8, 2012, 5:19:12 PM5/8/12
to APE Project
I add that I've a second problem... D'=
I've an error "BAD_PARAMS".

I send this request (that's the request wich return the error) :
Neotopia.Pipe.request.send('PNeotopia', { cmd: "Connexion", session:
Neotopia.SESSION });

And my JS Module on APE is :
var $Neotopia = {
        users: [],
        Objets: [
            { 'image':'http://mydomain.fr/buildset.png','x':0,'y':
0,'tile':464,'id':1,'index':1,'collision':false },
            { 'image':'http://mydomain.fr/buildset.png','x':1,'y':
0,'tile':464,'id':2,'index':1,'collision':false },
            { 'image':'http://mydomain.fr/buildset.png','x':2,'y':
0,'tile':464,'id':3,'index':1,'collision':false },
            { 'image':'http://mydomain.fr/buildset.png','x':3,'y':
0,'tile':464,'id':4,'index':1,'collision':false },
            { 'image':'http://mydomain.fr/buildset.png','x':5,'y':
2,'tile':58,'id':6,'index':1,'collision':true },
            { 'image':'http://mydomain.fr/buildset.png','x':5,'y':
3,'tile':116,'id':7,'index':1,'collision':false }
        ]

};

Ape.registerCmd("PNeotopia", false, function(params, infos) {
        if (!$defined(params.cmd)) return ["5000","NO_COMMAND_GIVEN"];

        switch (params.cmd) {
                case "Deplacement":
                        if (!$defined(params.deplacer)) return
["7000","DIRECTION_NOT_DECLARED"];
                        if (params.deplacer !== 0 && params.deplacer !
== 1 &&
params.deplacer !== 2 && params.deplacer !== 3) return
["7100","BAD_DIRECTION"];

                        var pipe = Ape.getPipe(params.pipe);
                        if (!$defined(pipe)) return ["4400",
"WHERE_S_THE_PIPE"];

                        if ($defined(infos.user.$Neotopia)) {
                                switch (params.deplacer) {
                                        case 0:
                                               
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].y++;
                                        break;
                                        case 1:
                                               
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].x--;
                                        break;
                                        case 2:
                                               
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].x++;
                                        break;
                                        case 3:
                                               
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].y--;
                                        break;
                                        default:
                                                return
["7100","BAD_DIRECTION"]
                                }

                                pipe.sendRaw('PN_dataPositions', {
                                        'name':
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].name,
                                        'id':
infos.user.getProperty("ID_Neotopia"),
                                        'direction': params.deplacer,
                                        'x':
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].x,
                                        'y':
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].y
                                });
                        }
                break;

                case "Connexion":
                        if (!$defined(params.session)) return
["6000","SESSION_NOT_DECLARED"];

                        if (!$defined(infos.user.$Neotopia)) {
                                infos.user.$Neotopia = true;

                                var getDATA = new Http("http://
mydomain.fr:80/APE-" +
params.session + "-getDATA.html");

                                getDATA.getContent(function (MyData) {
                                        var data = JSON.parse(MyData);

                                        $Neotopia.users[data.id] = {};
                                        $Neotopia.users[data.id].id =
data.id;
                                       
infos.user.setProperty("ID_Neotopia", data.id);

                                        $Neotopia.users[data.id].name
= data.name;

                                        var Positions =
data.position.split("|");
                                        var MyPositionX =
Positions[0];
                                        var MyPositionY =
Positions[1];

                                       
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].x =
MyPositionX;
                                       
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].y =
MyPositionY;
                                });

                               
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].pipe =
params.pipe;
                        }

                        return { 'raw': { 'name':
'PN_connexionReussie', 'data':
{ 'connexion': 'Reussie' } } };
                break;

                case "Joueurs":
                        if (!$defined(params.session)) return
["6000","SESSION_NOT_DECLARED"];

                        var pipe = Ape.getPipe(params.pipe);
                        if (!$defined(pipe)) return ["4400",
"WHERE_S_THE_PIPE"];

                        if ($defined(infos.user.$Neotopia)) {
                                var getPlayers = new Http("http://
mydomain.fr:80/plugins/json/
personnages-" + params.session + ".json");

                                getPlayers.getContent(function
(Players) {
                                       
pipe.sendRaw('PN_gestionJoueurs', {
                                                        'joueurs':
Players
                                        });
                                });
                        }
                break;

                case "Personnage":
                        var pipe = Ape.getPipe(params.pipe);
                        if (!$defined(pipe)) return ["4400",
"WHERE_S_THE_PIPE"];

                        if ($defined(infos.user.$Neotopia)) {
                                pipe.sendRaw('PN_Personnage', {
                                                'id':
infos.user.getProperty("ID_Neotopia"),
                                                'x':
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].x,
                                                'y':
$Neotopia.users[infos.user.getProperty("ID_Neotopia")].y
                                });
                        }
                break;

                case "Objets":
                        pipe.sendRaw('PN_Objets', {
                                'objets': $Neotopia.Objets
                        });
                break;

                default:
                        return ["5100","NO_COMMAND_FOUND"];
        }
        return 1;

});

Ape.addEvent("deluser", function (user) {
        if ($defined(user.$Neotopia)) {
                var setPosition = new Http("http://mydomain.fr:80/APE-
NONE-
setPOSITION=" + user.getProperty("ID_Neotopia") + "-" +
$Neotopia.users[user.getProperty("ID_Neotopia")].x + "-" +
$Neotopia.users[user.getProperty("ID_Neotopia")].y + ".html");

                setPosition.getContent(function (resultat) {
                        var pipe =
Ape.getPipe($Neotopia.users[user.getProperty("ID_Neotopia")].pipe);
                        if (!$defined(pipe)) return ["4400",
"WHERE_S_THE_PIPE"];

                       
$Neotopia.users[user.getProperty("ID_Neotopia")] = '';

                        pipe.sendRaw('PN_delJoueur', {
                                'id': user.getProperty("ID_Neotopia")
                        });
                });
        }

});

But when I send :
Neotopia.Pipe.request.send('PNeotopia', { cmd: "Connexion" });

That's return me the error 6000 : "SESSION_NOT_DECLARED".

Anyone can help me please ? :o

Thanks very much ! =D

Auryn

unread,
May 9, 2012, 1:44:42 PM5/9/12
to APE Project
My problems has been solved. \o/

But I've a final question... =D

When I connect my user on APE, I define his variables (MMO's
positions). But, when he don't lost the connexion (example : refresh)
and he send a second connexion, I wont that APE redefines his
variable. (APE must redefines this variables only when the user leave
APE and come back ! :/)

Auryn

unread,
May 9, 2012, 3:37:37 PM5/9/12
to APE Project
Ok that's don't work because I've forgotten that's the user is deleted
when we refresh the page.

Now my application work perfectly. Thanks very much all ! =D
Reply all
Reply to author
Forward
0 new messages