我是XMPP协议的新手,我试图在XMPP ANDROID中找到发送和接收IQ数据包的好例子,但是我失败了,我尝试使用以下代码块但是它没有帮助。
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);
我尝试使用此代码,但它没有向服务器发送任何消息。有人可以用正确的代码帮我吗?这样我就可以将我的智商发送到服务器并收到回复
答案 0 :(得分:1)
尚未测试过,但请尝试
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);
答案 1 :(得分:0)
我认为你应该使用正确的目的地址,包括来自目的地的资源,如本例所示
iq.setTo("destination@dominio_destination.com/recurso_destination");
现在您可以发送数据包:
connection.sendPacket(iq);