librelist archives

« back to archive

development question

development question

From:
Beginner Ti
Date:
2015-04-30 @ 21:20
Hi Guys,

I'm a C programmer so please forgive my questions if they are trivial.

What I'm trying to do is to write a program to let user log in a specific
room  right after the connection to jabber server is established. You could
imagine that this is like a customer service chat that when user logs in
from the webpage, we could make a room with name of his order number so
that will be unique.

I looked at on(event, callback) API method,  if I could have on('ready',
function() {...}); for example, but how to write the function to
join/create a room? Also, how to send a message to a specific user or
chatroom? My understanding is that everything is a xml block that you need
to send to the xmpp server, correct? so how could I prepare the proper xml
statements, make it the response body of a http request, then just send to
the BOSH service? if so, how do I populate the http request header?

Btw, I found this: https://github.com/jcbrand/converse.js/issues/16

but I don't know how I could make up that block myself, and send that to
the server. Are there any documentation/example that I could reference?

Any input will be greatly appreciated.

Thanks,
Rui

Re: [conversejs] development question

From:
Jc Brand
Date:
2015-05-01 @ 08:51
On Thu, Apr 30, 2015 at 02:20:59PM -0700, Beginner TI wrote:
>    I'm a C programmer so please forgive my questions if they are trivial. 
>    What I'm trying to do is to write a program to let user log in a specific
>    room  right after the connection to jabber server is established. You
>    could imagine that this is like a customer service chat that when user
>    logs in from the webpage, we could make a room with name of his order
>    number so that will be unique. 
>    I looked at on(event, callback) API method,  if I could have on('ready',
>    function() {...}); for example, but how to write the function to
>    join/create a room? Also, how to send a message to a specific user or
>    chatroom? My understanding is that everything is a xml block that you need
>    to send to the xmpp server, correct? so how could I prepare the proper xml
>    statements, make it the response body of a http request, then just send to
>    the BOSH service?
>    if so, how do I populate the http request header? 

This is all handled with the Strophe.js library. 
https://github.com/strophe/strophejs

See the Strophe.Builder function (as well as $build, $msg, $pres and $i).

You construct a Strophe.Builder representing the XML stanza you want and then
send it off with converse.connection.send.

>    Btw, I found this: [1]https://github.com/jcbrand/converse.js/issues/16
>    but I don't know how I could make up that block myself, and send that to
>    the server. Are there any documentation/example that I could reference? 
>    Any input will be greatly appreciated.

Sounds like this is close to what you need:
https://github.com/jcbrand/converse.js/issues/156

JC