tags:

views:

173

answers:

1

How can I query full roster using JSJAC XMPP client? I have tried following function for this, but it does not work:

function getRoster(con){
    var roster = new JSJaCIQ();
    roster.setIQ(null, 'get', 'roster_1');
    roster.setQuery(NS_ROSTER);
    con.send(roster);
 }
A: 

Instead of con.send, try:

con.sendIQ(roster, {result_handler: function(aIq, arg) {
    var node = aIq.getQuery()
    // do something with roster
  });

You need to have a callback that fires when the roster is returned. To be complete, set a error_handler as well, in case an IQ error is returned or you time out.

Joe Hildebrand
I have just changed the line:roster.setIQ(null, 'get', 'roster_1');withroster.setIQ(con.domain, 'get', 'roster_1');and it works now. I already have a IQhandler for processing the response.