In pipe.request.send('custom_name', {'author':author, 'msg':msg}); custom_name 
refer to the command you send to the server. So if you write << Custom name >>, 
you're actually calling the << custom_name >> command on the server (which 
doesn't exist by default). When you write <<  SEND >>, you're actually calling 
the SEND command on the server (which does exist) and this command return a RAW 
called << data >>. But the way the SEND command seems to work is really dumb : 
It keep the << msg >> part and discard the rest. That's why you don't received 
the "author" part. 


I guess the best way to achieve what you want would be to write a custom server 
side command. To do so, on the server, you edit the file << main.ape.js >> to 
include a new file. The inlinepush command is a good example as your code will 
be similar. Something similar to this actually: 
https://gist.github.com/lcharette/a392e61b21069f20a75b (I didn't this code...) 


An alternative would be to use the name found in the users properties. If you 
take the << name >> property defined in the start code, you could retrieve it 
in the << raw.data.from >> argument:
rawSendMsg: function (raw, pipe) {
    this.sendMsg(pipe, raw.data.from.name, raw.data.msg);
},

(Also FYI, according to the documentation, pipe.request.send('SEND', 
{'author':author, 'msg':msg}); and pipe.send({'author':author, 'msg':msg}); 
should be the same (Ref.: 
http://ape-project.org/docs/client/symbols/APE.Pipe.html#static_send)).


Finally, I used alert, but << console.log(raw) >> is better since you can 
navigate objects in the browser console. 



Hope this helps,

  - Louis


P.s.: You can also give a look at this alternate APE client which is much 
simpler and well documented : https://github.com/ptejada/ApePubSub



Le 2014-05-17 à 17:48, michael <[email protected]> a écrit :

> Hello, thanks for replying; When I alert the author it shows up as the 
> current user posting so it exists, and when i use raw.data.from and alert it; 
> it shows up as [Object Object].
> I am not sure on how my onRaw event should look as it is not intercepting any 
> of my custom raw names. such as pipe.request.send('custom_name', 
> {'author':author, 'msg':msg});
> this.onRaw('custom_name', this.sendMsg); is not picking up the message on 
> send unless i change it to onRaw('data');
> 
> this is my start function : 
> 
> 
> startCore: function () {
>         this.core.start({"name":this.options.SN});
>         console.log("start");
>     },
> 
> 
> 
> On Saturday, May 17, 2014 1:52:23 PM UTC-7, michael wrote:
> Hello, I am creating a chat and am having problems sending multiple values 
> and receiving them on an onRaw event. I am trying to send the author and the 
> msg to the users but raw.data.author is comming up as undefined while 
> raw.data.msg is defined. when i put this.onRaw('data') it works but 
> this.onRaw('SEND') does not. 
> this is inside the intialize function :
> 
>        this.onRaw('data', this.rawSendMsg);
>         this.addEvent('load', this.startCore);// load ape core
>         this.addEvent('ready', this.joinChannel);// once the ape core is 
> loaded connect to pipe/channel
>         this.addEvent('uniPipeCreate', this.channelJoined);
>         this.addEvent('multiPipeCreate', function(pipe) {// once the channel 
> is successfully joined
>             myPipe = pipe;
>             this.channelJoined();
>         });
> 
> 
> requestMsg: function (pipe, options) {
>                 myPipe.request.send('SEND', {'author':author, 'msg':'<span 
> style="color:#' + SNColorCur + '">' + sn + ': </span>' + ' ' + message});
>     },
>     rawSendMsg: function (raw, pipe) {
>         this.sendMsg(pipe, raw.data.author, raw.data.msg);
>     },
>     parseMessage: function(message){
>         return decodeURIComponent(message);// escape and return raw data for 
> use in sendMsg
>     },
>     sendMsg: function (pipe, from, message) { // function used to send 
> decoded message through rawDataEscape
>         $('.chatBoxmsginCon').append( // once rawDataEscape receives it, the 
> message will be sent to chat
>                     new Element('p', {'author':this.parseMessage(from), 
> 'class':'newMessage', html:this.parseMessage(message)}));
>                     $('.newMessage:last-of-type').hide().fadeIn(300);
>                         $('input[class=Chatmsg]').val("");
>                         this.scrollBot;// scroll chat to bottom for new 
> message
>     }
> 
> -- 
> -- 
> 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 unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to