質問

I have been writing a chat app for android.

I am implementing Google talk shared status messages feature. http://code.google.com/apis/talk/jep_extensions/shared_status.html

I have to send this stanza

<iq type='get' to='gmail.com'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>

My code (using SMACK api) is:

    final IQ iq = new IQ() {
        public String getChildElementXML() { 
            return "<query xmlns='http://jabber.org/protocol/disco#info'/>"; 
        }
    };

    iq.setTo("gmail.com");
    iq.setType(IQ.Type.GET);

    Log.w("IQ", "Prepared packet " + iq.toXML());
    Log.w("IQ", "Sending 1");
    connection.sendPacket(iq);

I am expecting to receive the following packet:

<iq xmlns='jabber:client' from='gmail.com' type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <identity category='server' type='im' name='Google Talk'/>
    <feature var='http://jabber.org/protocol/disco#info'/>
    <feature var='google:jingleinfo'/>
    <feature var='google:roster'/>
    <feature var='google:nosave'/>
    <feature var='google:setting'/>
    <feature var='google:shared-status'/>
    <feature var='http://jabber.org/protocol/archive#otr'/>
    <feature var='google:mail:notify'/>
    <feature var='http://jabber.org/protocol/archive#save'/>
    <feature var='http://jabber.org/protocol/rosterx'/>
  </query>
</iq>

My listener receives the packet:

public void processPacket(Packet    
    //IQ iq = (IQ) packet;
    Log.w("IQ", "Packet received " + packet.toXML());
}

On receiving, I am getting the following log:

03-17 08:05:43.129: W/IQ(1050): Packet received <iq id="fYhYL-4" to="abdurrahim.ceg@gmail.com/androidC2AEBEEF" from="gmail.com" type="result"></iq>

What am I doing wrong?

Thanks in advance!

役に立ちましたか?

解決

There was no problem with sending the packets. I has to write an IQProvider or PacketExtensionProvider to parse the incoming packets since smack doesn't understand these custom packets.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top