xmppサーバテストを自動化しようとしています。私はxmppサーバにxmlスタンザを送り、応答を確認します。私は正常にスタンザを送信することができますが、私は応答を取得するのに問題があります。IQ応答を取得する方法
私はSmack 4.1.8 apiを使用しています。
<iq id='123' from='[email protected]' to='[email protected]/resource' type='get'>
<control xmlns='http://domain.com/powertalk/control/2.0'>
<point id='00000000/relay_1A' />
<point id='00000000/relay_2A' />
</control>
</iq>
を、私は、この使用してPSIクライアントを送信すると、私はお返しに、次を得る:
これは私が送りますスタンザで
<iq from="[email protected]/resource" type="result" to="[email protected]/resource" id="17">
<control xmlns="http://domain.com/powertalk/control/2.0">
<point val="0" id="00000000/relay_1A" ts="2016-08-30T15:52:41.068308Z"/>
<point val="0" id="00000000/relay_2A" ts="2016-08-30T15:52:41.148337Z"/>
</control>
</iq>
私が取得したいものであること。私が実際に受け取る何
は次のとおりです。ここで
<iq to='[email protected]/resource' from='[email protected]' id='c8QbM-8' type='result'>
<query xmlns='jabber:iq:roster'></query>
</iq>
は私のコードです。私は何らかのカスタムIQプロバイダをやらなければならないと思いますが、私が見つけた例は主にSmack 3.x用であり、有効ではありません。
AbstractXMPPConnection mConnection = this.getConnection();
try
{
final IQ iq = new IQ("control","http://domain.com/powertalk/control/2.0")
{
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml)
{
xml.rightAngleBracket();
xml.halfOpenElement("point");
xml.attribute("id", "00000000/relay_1A");
xml.append(" />");
xml.halfOpenElement("point");
xml.attribute("id", "00000000/relay_2A");
xml.append(" />");
return xml;
}
};
iq.setStanzaId("123");
iq.setFrom("[email protected]");
iq.setType(IQ.Type.get);
iq.setTo("[email protected]/resource");
mConnection.sendStanza(iq);
// Receive the packet
IQ iqReceived = (IQ)collector.nextResult(50000);
// Stop queuing results
collector.cancel();
System.out.println("Sent: " + iq.toXML());
System.out.println("Received: " + iqReceived.toXML());
System.out.println("Collector size = " + collector.getCollectedCount()); //returns 0
System.out.println("collector pollResult = " + collector.pollResult()); //returns null
System.out.println("collector StanzaFilter = " + collector.getStanzaFilter()); //returns: StanzaIdFilter: id=123
}
catch (Exception e)
{
e.printStackTrace();
}
}
私はここで何が欠けていますか?
私はスマックのソースコードを見てお勧めします。 XMPPのpingコードは、IQ pingを送信して結果を受信する簡単な例です。 – Flow
あなたはこの通信にopenfireカスタムプラグインを使用していますか? – Saveen
私はpingの理解から、それはtrue/falseを返します。私はサーバーからIQの結果を取得する方法を見ていない。上記の例でPSIクライアントが行う結果を返す方法を説明できますか? – user6776106