No need to route the data in the server. You could could just handle
the data at the source, the client. But if you really want to send
that extra raw just write a server module that hooks the SEND command,
from there you could return the sender its raw.

Sent from my iPhone

On May 11, 2012, at 10:00 AM, Maxus <[email protected]> wrote:

> Seems I've hit a road block again. Can't seem to work out how I can
> add to my existing code so that when a user clicks a button they not
> only receive the existing return sent to everyone, but also receive an
> additional message that is only sent to them.
> I thought that when the user joined the channel there is a pubid that
> is created for them which I could send to the server module and then
> use a command to send a raw back to this specified pubid? This is the
> last thing I need to work out. I'm sorry if this has been answered a
> thousand times, I promise I've searched here and on the ape site to no
> avail.
>
> Cheers
>
> On May 11, 2:27 pm, Maxus <[email protected]> wrote:
>> Thanks very much Louis, seems to be fixed with your suggestions!!! :)
>>
>> For any others having similar difficulty I had to send the raw with:
>> client.core.getPipe(myPipe).request.send('getInfo', {'testData':
>> 'ABC'});
>> Otherwise the pipe was undefined when it hit the server module.
>>
>> On May 11, 1:24 pm, Louis Charette <[email protected]> wrote:
>>
>>
>>
>>
>>
>>
>>
>>> Hi there,
>>
>>> You are adding two times the event "multiPipeCreate". That's one thing. The 
>>> second thing, you don't have to be in the "addEvent" function to send a 
>>> raw. The way you did it:
>>> 1) the client connect to the server.
>>> 2) When the connection is made to the channel, the event "multiPipeCreate" 
>>> is fired:  the client start listening for the "info" raw
>>> 3) When you press the testButton, the event "multiPipeCreate" is redefined 
>>> and you ask to send the raw when this same event is fired again (which 
>>> won't append since it already been fired. It will fire again if you join a 
>>> new channel)
>>
>>> You can send a Raw outside of the "multiPipeCreate". Try something like 
>>> this:
>>
>>> var client;
>>> var myPipe;
>>
>>> $(document).ready(function(){
>>>         client = new APE.Client();
>>>         client.load({'channel': '*tapdicom'});
>>>         client.addEvent('load', function() {
>>>                 client.core.start({'name': new 
>>> Date().getTime().toString()});
>>>         });
>>
>>>         client.addEvent('multiPipeCreate', function(pipe) {
>>>                 myPipe = pipe.getPubid();
>>>         });
>>
>>>         client.onRaw('info', function(params) {
>>>                 console.log('testReturn: '+params.data.testReturn);
>>>         });
>>
>>>         $('#testButton').on('click', function(){
>>>                 console.log('clicky');
>>>                 client.core.request.send('getInfo', {'testData': 'ABC'});
>>>         });
>>
>>> });
>>
>>> Not sure, but you can also try "client.core.getPipe(myPipe).send('getInfo', 
>>> {'testData': 'ABC'});" instead of "client.core.request.send('getInfo', 
>>> {'testData': 'ABC'});".
>>> I use my own class, so I'm not sure of the real syntax.
>>
>>>   - Louis
>>
>>> Le 2012-05-10 à 22:21, Maxus a écrit :
>>
>>>> Maybe I'm approaching this wrong? Here is simplified version of what
>>>> I'm trying to do.
>>
>>>> <!DOCTYPE html PUBLIC "-//W4C//DTD XHTML 1.0 Transitional//EN" "http://
>>>> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" dir="ltr"
>>>> lang="en">
>>>> <head>
>>>>  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/
>>>> jquery.min.js" type="text/javascript"></script>
>>>>  <script type="text/javaScript" src="./apeDir/APE_JSF/Clients/
>>>> JavaScript.js"></script>
>>>>  <script type="text/javaScript" src="./apeDir/APE_JSF/Demos/
>>>> config.js"></script>
>>>>  <script>
>>>>    var client;
>>>>    $(document).ready(function(){
>>>>           client = new APE.Client();
>>>>           client.load({'channel': '*tapdicom'});
>>>>           client.addEvent('load', function() {
>>>>               client.core.start({'name': new
>>>> Date().getTime().toString()});
>>>>           });
>>
>>>>       client.addEvent('multiPipeCreate', function(pipe) {
>>>>              client.onRaw('info', function(params) {
>>>>                 console.log('testReturn: '+params.data.testReturn);
>>>>               });
>>>>           });
>>
>>>>       $('#testButton').on('click', function(){
>>>>              console.log('clicky');
>>>>          client.addEvent('multiPipeCreate', function(pipe) {
>>>>             pipe.request.send('getInfo', {'testData': 'ABC'});
>>>>          });
>>>>      });
>>>>    });
>>>> </script>
>>>> </head>
>>>> <body>
>>>> <div id='testButton'>click</div>
>>>> </body>
>>>> </html>
>>
>>>> Click the button, console displays message but no event is fired
>>>> according to network. It's driving me insane! I had a bit of a hard
>>>> time getting the SQL up and running (spider monkey error), finally got
>>>> that sorted and converted everything over from my original ajax code
>>>> and it was working great from my testing page but as soon as I try to
>>>> trigger a send from elsewhere in the code it fails. :(
>>
>>>> On May 11, 11:22 am, Maxus <[email protected]> wrote:
>>>>> Actually cant be a channel issue as the server side module prints to
>>>>> the ape log as soon as 'getinfo' is called. :/
>>
>>>>> On May 11, 10:20 am, Maxus <[email protected]> wrote:
>>
>>>>>> Thanks for the reply, tried both with no success. I know it's not
>>>>>> scope completely because if I declare 'client' globally (placing 'var
>>>>>> client;' at the top of doc) it knows about it. ie changing
>>>>>> 'client.addEvent()' to 'client.add1Event'  produces Uncaught
>>>>>> TypeError: Object [object Object] has no method 'add1Event'. But
>>>>>> doesn't seem to fire when its right.
>>>>>> Its like the object is there but they aren't on the same channel?
>>
>>>>>> On May 11, 12:28 am, Omar Chanouha <[email protected]> wrote:
>>
>>>>>>> Try removing the var from the client declaration. Or declare client
>>>>>>> outside of the document.ready
>>
>>>>>>> -O
>>
>>>>>>> On Thu, May 10, 2012 at 8:49 AM, Maxus <[email protected]> wrote:
>>>>>>>> Can someone please help, I'm sure there is something simple I'm
>>>>>>>> missing but I just can't get it.
>>
>>>>>>>> I'm including Clients/JavaScript.js, Demos/config.js and my custom js
>>>>>>>> script file in the parent document. Within the js script file I'm
>>>>>>>> trying to use APE but am having issues.
>>
>>>>>>>> Within a jquery document ready function I'm loading the server etc.
>>>>>>>> ie:
>>
>>>>>>>> var client = new APE.Client();
>>
>>>>>>>> client.load({'channel': 'test'});
>>>>>>>> client.addEvent('load', function() {
>>>>>>>>   client.core.start({'name': new Date().getTime().toString())});
>>>>>>>> });
>>>>>>>> client.addEvent('multiPipeCreate', function(pipe) {
>>>>>>>>   client.onRaw('info', function(params) {
>>>>>>>>      console.log('info: '+params.data.item1+' - '+params.data.item2+'
>>>>>>>> - '+params.data.item3);
>>>>>>>>   });
>>>>>>>> });
>>
>>>>>>>> This works fine. I then have a bunch of functions which I'd like to
>>>>>>>> add send events to. So I try adding this code to them:
>>
>>>>>>>> client.addEvent('multiPipeCreate', function(pipe) {
>>>>>>>>   pipe.request.send('getInfo', {'input1': 'abc', 'input2': 'xyz',
>>>>>>>> 'input3': '123'});
>>>>>>>> });
>>
>>>>>>>> Its strange as it only ever works if it's placed straight below the
>>>>>>>> top code that creates the client and connects to the server... Even if
>>>>>>>> its placed directly within an onclick listener, within the document
>>>>>>>> ready block it fails to fire. I'm sure it's scope related but can't
>>>>>>>> work it out. Please help as I'm losing the little hair I have left! :)
>>
>>>>>>>> Thanks
>>>>>>>> Maxus
>>
>>>>>>>> --
>>>>>>>> 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/
>>
>>>> --
>>>> 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/
>
> --
> 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/

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