Dominik a écrit :
> Hi!
>
> Thanks a lot, these information were really useful for me, I got it
> working right now!
> Don't get angry on me, but I got 2 more questions ;)
>
This is the purpose of this list :)
> 1) Object Definitions on server side
> In the development process it is really helpful to know which object
> provides which functions and attributes. On client-side I can just
> look into the Source-JS-Files (for example Pipe.js / MultiPipe.js).
> But where are the definitions on the server-side? Are there any
> Javascript- or C-Files I can extract the definitions from? Because
> obviously the definitions of server- and client-side differ a bit or
> am I wrong with this?
>
All objects/functions are defined in ./modules/libape-spidermonkey.c and
yes it's not the same API (it cannot be ;))
> 2) Return a custom raw on a command
> I want to return a custom raw when a client sends a certain command.
> The wiki article about server-side JS modules shows, that this can be
> implemented by returning a custom raw in the registerHookCmd-function.
> But when I do this, the registerCmd-function is not executed any more,
> because the registerHookCmd-function obviously is called before that.
> Returning a custom raw in the registerCmd-function itself has no
> effect, so I am wondering how to return a custom raw and additionally
> call the registerCmd-function...
>
There is 2 differents command :
- A command where the user needs to be connected
- A command where the user doesn't need to be connected.
This is defined by the second argument of registerCmd(). (true/false)
An user must be connected in order to send it a RAW.
Ape.registerCmd('foo', true, function(params, info) {
info.user.pipe.sendRaw("customraw", {'foo':'bar'});
info.user.pipe.sendRaw("customraw2", {'foo':'bar'});
});
Indeed, in the case of a command where the user doesn't need to be
connected :
Ape.registerCmd('bar', false, function(params, info) {
// info.user <= don't exists - Can't send a raw
});
But I started to implement something like this to send a raw to a
"non-connected user" :
return { 'raw':{'name':'customraw', 'data':{'foo':'bar'}} };
It only works for registerHookCmd at the moment, but i'll write it for
registerCmd as soon as possible (this week).
>But when I do this, the registerCmd-function is not executed any more,
>because the registerHookCmd-function obviously is called before that.
Indeed :
Ape.registerHookCmd("foo", function(params, infos) {
return 1; // continue;
return 0; // stop (don't call the registerCmd)
return { 'raw':{'name':'customraw', 'data':{'foo':'bar'}} }; // stop
the execution (same as return 0;)
});
Voilà ;)
Anthony
>
> Thanks for your help!
> Dominik
>
>
>
> On Oct 18, 5:00 pm, Nicolas Trani <[email protected]> wrote:
>
>> Hi,
>>
>> the move demo have an error with multiPipeCreate (i didn't finish to
>> port the demo to 1.0).
>>
>> multiPipeCreate works like that :
>>
>> this.addEvent('multiPipeCreate', function(pipe, options){
>>
>> });
>>
>> I wrote some tutorial for the client side on the wiki :
>>
>> http://www.ape-project.org/wiki/index.php/Category:Tutorial
>>
>> (some tutorials are not yet fully finished and might contains a lot of
>> english mistake)
>>
>> Regards.
>>
>>
>>
>>
>>
>> Dominik wrote:
>>
>>> Hi!
>>>
>>>> For your first question I think you misunderstood. This article is
>>>> about "Server-Side javascript", not client side :)
>>>> APE 1.0 support Javascript module for the server. (Look at your ./
>>>> APE_Server/scripts/ directory).
>>>>
>>> Yes, sorry, I meant the APE Log told me that Ape.pipe() ist not a
>>> function, not the Browser ;)
>>> I tried new Ape.pipe(), but this also does not give me a valid pipe
>>> (for example:
>>> var mypipe = new Ape.pipe();
>>> --> mypipe.pubid is undefined and mypipe.send is not a function...).
>>>
>>> I really don't know what's going wrong there :/
>>>
>>> I also do not really understand the "multiPipeCreated"-Event on the
>>> client side.
>>> The Move-Demo for example defines:
>>>
>>> this.addEvent('multiPipeCreate', function(type, pipe, options){
>>> if(type=='multi') this.pipe = pipe;
>>> });
>>>
>>> I tried this in my application and it does not work, because type
>>> never has the value "multi", but is a huge array full of weird
>>> information.
>>> The pipe-parameter furthermore does not give me a pipe-object, but is
>>> an array with information about the userpipes and the channel-pipe.
>>>
>>> For example:
>>> this.addEvent('multiPipeCreate', function(type, pipe, options){
>>> jQuery("#debug").append("<br>Pipe created");
>>> alert(pipe.toSource());
>>> if(type=='multi')
>>> {
>>> jQuery("#debug").append("<br>Pipe found");
>>> this.pipe = pipe;
>>> }
>>> });
>>>
>>> The alert shows:
>>>
>>> ({users:[{casttype:"uni", pubid:"8f30f9d3b67f2c59ae72d0e174e68467",
>>> properties:{mypipe:"[object pipe]", name:"dominik"}, level:1}], pipe:
>>> {casttype:"multi", pubid:"41eeb70009b15b1bd81a93e41bcf5fbf",
>>> properties:{name:"apetest"}}})
>>>
>>> I'm really confused about this pipe-thing ;)
>>>
>>>> You can avoid this by loading "Sessions.js". With this, every tabs/
>>>> window you open connect the same user with the same message queue
>>>> (everything is synchronized).
>>>>
>>> Works great, thanks!
>>>
>>>>> But when
>>>>> I close one tab, he needs some time to realize that the user has left
>>>>> (so just realizes it when the open connection of this tab times out).
>>>>> Is there a way to immediately tell the server that a user has left
>>>>> when I close a tab/window?
>>>>>
>>>> Indeed, some browser don't have a good deal with "onunload" event. So,
>>>> APE Server can't know when a user left. (You can tune the timeout in ./
>>>> src/main.h)
>>>>
>>> Ok, thanks for the info!
>>>
>>> Thanks for the help so far!
>>> Dominik
>>>
>> --
>> Nicolas Trani - Développeur web
>> Weelya - Improve the webhttp://www.weelya.com
>>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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/
-~----------~----~----~----~------~----~------~--~---