本文整理汇总了Java中org.jivesoftware.smack.AbstractXMPPConnection.sendStanza方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractXMPPConnection.sendStanza方法的具体用法?Java AbstractXMPPConnection.sendStanza怎么用?Java AbstractXMPPConnection.sendStanza使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.AbstractXMPPConnection
的用法示例。
在下文中一共展示了AbstractXMPPConnection.sendStanza方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendRestDocument
import org.jivesoftware.smack.AbstractXMPPConnection; //导入方法依赖的package包/类
@Override
public ResourceDocument sendRestDocument(XmppURI uri, ResourceDocument document) throws XMPPException, IOException, SmackException {
AbstractXMPPConnection connection = this.connectionManager.getConnection();
// create an set IQ stanza to uri
RestIQ setIQ = new RestIQ(uri, document);
// send stanza
connection.sendStanza(setIQ);
// wait for response
StanzaFilter filter = new AndFilter(new IQReplyFilter(setIQ, connection));
PacketCollector collector = connection.createPacketCollector(filter);
IQ resultIQ = collector.nextResultOrThrow();
if(resultIQ instanceof RestIQ) {
// create rest doc
return ((RestIQ) resultIQ).getResourceDocument();
} else {
throw new SmackException("Wrong RestIQ has been passed");
}
}
示例2: getXwadlDocument
import org.jivesoftware.smack.AbstractXMPPConnection; //导入方法依赖的package包/类
@Override
public ResourceTypeDocument getXwadlDocument(XmppURI uri) throws XMPPException, IOException, SmackException {
AbstractXMPPConnection connection = this.connectionManager.getConnection();
// create an get IQ stanza to uri
IQ getIQ = new GetXwadlIQ(uri);
// send stanza
connection.sendStanza(getIQ);
// wait for response
StanzaFilter filter = new AndFilter(new IQReplyFilter(getIQ, connection));
PacketCollector collector = connection.createPacketCollector(filter);
IQ resultIQ = collector.nextResultOrThrow();
if (resultIQ instanceof XwadlIQ) {
// create xwadl
return ((XwadlIQ) resultIQ).getXwadl();
} else {
throw new SmackException("Wrong IQ has been passed");
}
}