powered by Jive Software

Waiting for response

Hi guys

I’'m now working on supporting RPC in Smack… And I have the folowing situation:

I created an RPCPaket class derived from IQ which can encode an RPC call in a proper XML standart.

I’'m sending it with XMPPConnection.sendPacket() function to the external server component written in Perl (it is already supports RPC). This component sends me a standart RPC response (IQ stanza).

What I need is to develop an RPCCall routine which can send a packet and WAIT for this response in order to parse it and return a result in the RETURN statement.

Could you please direct me to the most correct way hoe to make it with Smack classes ?

Thank a lot.

You’'ll want to use a PacketCollector to wait fora response the IQ. Please see:

http://www.jivesoftware.org/builds/smack/docs/latest/documentation/processing.ht ml

Specifically:

  1. Create a packet collector using a PacketIDFilter that uses the ID of the IQ packet you’'re going to send.

  2. Register the packet collector.

  3. Send the IQ.

  4. Call nextResult() to wait for a response to your IQ, or nextResult(long) to wait a specific amount of time for a reply.

Regards,

Matt