powered by Jive Software

Create a listener which can perform an answer

Hi,

For my work, i have to develop a Jabber client in Java. To do that, i use smack. However, i don’'t understand a thing about IQProviders etc.

Create a new instance of a specific classe when we receive an IQ packet is a very good idea. But why don’'t we have the ability to make a response to this packet.

For example, i have to manage the jabber:iq:version packet. So when i receive an empty jabber:iq:version packet, i would like to make a response! It would be easy to add a new method such as makeResponse which is called when the packet has been parsed.

Currently, the only way we have to make responses is to do that in the getChildElementXML but it’'s very ugly !

Maybe i forgot something but if not, i’‘ll change the smack sources to do that and i’'ll can send you modifications.

Regards,

Aurélien

if the packet that is made by your iqprovider is an iq packet then thats the same class you can use to form a response and then send it with connection.sendPacket()

I don’'t think i understood the way to use this library.

For me, i would like to have two threads. The first one is listening the Jabber connection. When it receives data, i would like it creates an instance of the class which manage this sort of packet (by “manage the packet”, i want to say the instance is initialized with the value of the packets (like IQ does) and after , a method is called if an answer should be send). The second thread is the “main” thread where i do what i want like print my messages etc.

By this way, when someone send to me a jabber:iq:version, for example, my class send him back the answer! Another example: when i receive a message from Bob, my class can print the message or doing anything else to inform the second thread or the client a message is available.

And because this very good thing to add iq event manager in a XML file is available. I don’'t want to develop elsewhere a loop where i ask to receive the jabber:iq:version to answer etc. It should be in the same class that above!