I solved the problem without using user.quit(), the code:

Ape.registerCmd('leavePage', true, function(params, infos) {
        try{
          Ape.log("event: leavePage user: " +
infos.user.getProperty('name').toLowerCase());
          var chan = Ape.getChannelByPubid(params.pipe);
          infos.user.left( chan );
          userlist.erase(infos.user.getProperty('name').toLowerCase());
        }catch(err){
          Ape.log("Error cuando: a client has disconnected event:
leavePage");
        }
});
Ape.registerCmd('leaveMain', true, function(params, infos) {
    try{
                Ape.log("event: leaveMain user: " +
infos.user.getProperty('name').toLowerCase() );
                var chan = Ape.getChannelByPubid(params.pipe);
                infos.user.left( chan );
                userlist.erase(infos.user.getProperty('name').toLowerCase());
        }catch(err){
          Ape.log("Error cuando: a client has disconnected");
        }
});

Regards.

On 12 abr, 11:39, Alejandro Micheloud <[email protected]>
wrote:
> just in case, my server code:
>
> Ape.registerCmd('leavePage', true, function(params, infos) {
> try{
>   infos.user.quit();}catch(err){
>
>   Ape.log("Error: leavePage");}
> });
>
> Ape.registerCmd('leaveMain', true, function(user, infos) {
>     try{
>   infos.user.quit();}catch(err){
>
>   Ape.log("Error:  leaveMain ");
>
> }
> });
>
> Client code:
>
> // onUnload
> $(window).unload(function() {
> client.pipe.request.send('leavePage');
>
> });
>
> // onCloseSession
> function closeSession(){
> client.pipe.request.send('leaveMain');
> client = new APE.Client();
> client.load();
>
> }
>
> Regards.
>
> El lunes, 28 de noviembre de 2011 13:02:39 UTC-3, Evertjan Garretsen
> escribió:
>
>
>
>
>
>
>
>
>
> > Hi developers,
>
> > i was not paying attention when writing a code for my server-side
> > Javascript for APE server 1.1.0. I tried to send a sendResponse()
> > after infos.user.quit(). This will not work (duh :-) ), for the user
> > has already left, but i don't think the server should crash with a
> > segmentation fault due to this mistake.
>
> > When i placed the sendResponse just before the infos.user.quit(), the
> > response never got to the client, but the user was exited from the Ape
> > server. Is there a simple way to send a reponse just before the user
> > quits? I think i read something from another user, suggesting the
> > event onbeforequit to be added to the Ape server. I also think this is
> > a good idea. I solved the problem by creating my own quit function,
> > which first performs the sendResponse and sets a
> > Ape.setTimeout(function(infos){infos.user.quit()},1000,infos). But to
> > me it feels like a hack.
>
> > Maybe the quit function can be adapted in the future to take a
> > function as parameter to perform just before the user is quitted?
>
> > Kind regards,
>
> > Evertjan

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