0

I am new to XMPP protocol, i tried to find good examples of sending and receiving IQ packets in XMPP ANDROID, but i failed, I tried using the following chunk of code but it did not help.

CODE:

final IQ iq = new IQ() {
    public String getChildElementXML() { 
    return "<iq type='get' from='9f30dacb@web.vlivetech.com/9f30dacb' id='1'> <query xmlns='http://jabber.org/protocol/disco#info'/></iq>"; // here is your query
    //"<iq type='get' from='9f30dacb@web.vlivetech.com/9f30dacb' id='1'> <query xmlns='http://jabber.org/protocol/disco#info'/></iq>";
     }};
    // set the type
iq.setType(IQ.Type.GET);
// send the request
connection.sendPacket(iq);

I tried using this code, but it did not send any message to server. can somebody help me with right piece of code? so that i can send my IQ's to the server and receive the response

Hassaan Rabbani
  • 2,469
  • 5
  • 30
  • 55
  • possible duplicate of [Sending and Receiving Custom IQ XMPP ANDROID ASMACK](http://stackoverflow.com/questions/22405405/sending-and-receiving-custom-iq-xmpp-android-asmack) – Flow Mar 14 '14 at 13:52

2 Answers2

1

Haven't tested it yet, but try

    IQ iq = new IQ();
    iq.setTo("destination@server");
    iq.setFrom("9f30dacb@web.vlivetech.com/9f30dacb");
    iq.setType(IQ.Type.GET);        
    iq.setPacketID("1");
    connection.sendPacket(iq);
Hafizh Herdi
  • 180
  • 1
  • 13
  • how about sending basic Message packet, does that work? Just to make sure if server is up and users are connected – Hafizh Herdi Mar 11 '14 at 02:29
  • a simple message packate is working, but i am unable to send IQ. i guess there are syntax issues or some logical mistake that i am unaware of – Hassaan Rabbani Mar 11 '14 at 09:01
0

I think you should use the correct address of destination, that includes the resource from destination, like this example

iq.setTo("destination@dominio_destination.com/recurso_destination");

Now you can send the packet:

connection.sendPacket(iq);
yiperu
  • 31
  • 3