IQ / Packet extensions

Warm Greetings

Is it mandatory to place new IQ subclass or PacketExtension under org.jivesoftware.smackx.packet ? would be enough if the providers registration is done properly to the actual location of the new class ?

-Rajesh

Rajesh,

You can put Extension or IQ classes in any package you’'d like. Let us know if you have any problems getting it setup.

Regards,

Matt

Matt

I’'m actually trying to query the server for a list of available conference rooms using iq browse.

I have already read through a similar post on the forum and have tried to code a packet extension, half way through I suspected that I have to use a PacketCollector since I need the output to display a list for selection.

How do I go about in this case and considering that the query would return multiple results depending on the number of rooms.

I think this sounds vague but I’‘ll try to post some code and the debug output in the morning as I don’'t have them on this PC.

-Rajesh

The following is the debug output of the conference query

testjabber:iq:conferenceFunRoomjabber:iq:conference

  • Rajesh

When you write a custom packet extension you get to parse all the XML yourself. Therefore, you should be able to assemble whatever types of objects you’'d like. Does that make sense, or do I not understand the problem?

Thanks,

Matt

  • May be forum must have a delete option, I did not put in

Dear Matt,

I have written a Packet (extends IQ) and Provider class (implements IQProvider ) for my requirement. I have also made entries in the Smack providers file. I am using the following code to test the same.

RoomInfo ri = new RoomInfo(); ri.setTo("conferencing"); PacketCollector collector = conn.createPacketCollector(new PacketIDFilter(ri.getPacketID())); conn.sendPacket(ri); IQ result = (IQ)collector.nextResult(5000); System.out.println("Result : " + result); if (result != null && result.getType() == IQ.Type.RESULT) {
     RoomInfo roomResult = (RoomInfo)result;
     System.out.println(roomResult.containsRoom("test"));     
}

My debug finding show that the correct iq is being passed to the server and the server returns the result. The result is being correctly parsed by my Provider class.

What does not happen is that the above code does not give a proper Packet result but only null

Am I missing something here ?

-Rajesh

Are you sure that null is what you get back? Perhaps the IQ is not of type RESULT? How doe you test that it’'s null?

Regards,

Matt

Dear Matt,

The System.out.println prints null and any operation gives the NullPointer exception clearly showing that the result is null.

-Rajesh

Can you paste in the XML showing the packet being sent and then the reply from the debug window?

Thanks,

Matt

Dear Matt

Please find the XML below. I can also post the Packet and Provider code if needed, but it will be long.

Query

=====

<query

xmlns=“jabber:iq:browse”>

Reply

=====

<item category=“service” jid=“conferencing” name=“conferencing”

type=“conference” xmlns=“jabber:iq:browse”>testjabber:iq:conference

-Rajesh

Matt

Any pointers for me, thanks.

-Rajesh

Hi, Rajesh.

I confess that I have not used a PacketCollector, so this might be off base. Does the pollResult() method give you anything different?

Have you tried using a PacketListener/Filter combination?

Good luck,

Keith

Rajesh,

If you want you can send me by email your code and an example to execute. I’‘ll try to reproduce the problem and see what’'s going on.

Regards,

– Gato

Dear Gato,

Have mailed the files to your hotmail. I actually have sent two mails as I missed the attachments once.

-Rajesh

Strange. So far I didn’'t receive any email…

– Gato

Rajesh,

I think the problem is that in your code you are creating a PacketCollector with a filter on the RoomInfo’'s packetID and the answer that you receive has an empty id. Therefore, the PacketCollector will never process the answer.

Regards,

– Gato

Dear Gato

I tried to replace the filter to something as below

PacketFilter filter =  new PacketFilter() {
          public boolean accept(Packet packet) {
             return true;
               }
}; PacketCollector collector = conn.createPacketCollector(filter);

I was hoping that the above would catch any Packet that come in but it does not catch my RoomInfo packet. My debug shows that the server returns the result !

-Rajesh

Dear Gato

Looking at the server response as follows

testjabber:iq:conference

I actually need to use the data on the tags, shouldn’'t I look at using a PacketExtension rather than an IQProvider ?. If this is correct then the Smack documentation says IQ Packets can not have packet extensions !

I seem to be going in circles here or atleast is there a way for me to get the entire XML returned by the server ? I could do my own parsing to take the results.

Currently I am only abe to get the iq tag and not the entire XML including the item tag

-Rajesh

Rajesh,

If you are receiving an IQ packet then you should have an IQ subclass to represent the received packet.

I tried to reproduce the XML that you’‘re receiving but jabber.org answers a very similar XML but not your XML. I’‘d like to reproduce the exact problem in order to see what’'s going on. Can you give me this information?

Currently I am only abe to get the iq tag and not the entire XML including the item tag

I don’'t understand what you are saying. BTW, does your server support disco? AFAIK, the XMPP community is replacing jabber:iq:browse with disco and Smack currently supports disco.

Regards,

– Gato