本文整理汇总了Java中org.jivesoftware.smackx.packet.DiscoverItems.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java DiscoverItems.setTo方法的具体用法?Java DiscoverItems.setTo怎么用?Java DiscoverItems.setTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.packet.DiscoverItems
的用法示例。
在下文中一共展示了DiscoverItems.setTo方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: discoverItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Returns the discovered items of a given XMPP entity addressed by its JID and
* note attribute. Use this message only when trying to query information which is not
* directly addressable.
*
* @param entityID the address of the XMPP entity.
* @param node the attribute that supplements the 'jid' attribute.
* @return the discovered items.
* @throws XMPPException if the operation failed for some reason.
*/
public DiscoverItems discoverItems(String entityID, String node) throws XMPPException {
// Discover the entity's items
DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET);
disco.setTo(entityID);
disco.setNode(node);
// Create a packet collector to listen for a response.
PacketCollector collector =
connection.createPacketCollector(new PacketIDFilter(disco.getPacketID()));
connection.sendPacket(disco);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
return (DiscoverItems) result;
}
示例2: publishItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Publishes new items to a parent entity and node. The item elements to publish MUST have at
* least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which
* specifies the action being taken for that item. Possible action values are: "update" and
* "remove".
*
* @param entityID the address of the XMPP entity.
* @param node the attribute that supplements the 'jid' attribute.
* @param discoverItems the DiscoveryItems to publish.
* @throws XMPPException if the operation failed for some reason.
*/
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
throws XMPPException {
discoverItems.setType(IQ.Type.SET);
discoverItems.setTo(entityID);
discoverItems.setNode(node);
// Create a packet collector to listen for a response.
PacketCollector collector =
connection.createPacketCollector(new PacketIDFilter(discoverItems.getPacketID()));
connection.sendPacket(discoverItems);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
}
示例3: publishItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Publishes new items to a parent entity and node. The item elements to
* publish MUST have at least a 'jid' attribute specifying the Entity ID of
* the item, and an action attribute which specifies the action being taken
* for that item. Possible action values are: "update" and "remove".
*
* @param entityID
* the address of the XMPP entity.
* @param node
* the attribute that supplements the 'jid' attribute.
* @param discoverItems
* the DiscoveryItems to publish.
* @throws XMPPException
* if the operation failed for some reason.
*/
public void publishItems(String entityID, String node,
DiscoverItems discoverItems) throws XMPPException {
discoverItems.setType(IQ.Type.SET);
discoverItems.setTo(entityID);
discoverItems.setNode(node);
// Create a packet collector to listen for a response.
PacketCollector collector = connection
.createPacketCollector(new PacketIDFilter(discoverItems
.getPacketID()));
connection.sendPacket(discoverItems);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
}
示例4: discoverItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Returns the discovered items of a given XMPP entity addressed by its JID and
* note attribute. Use this message only when trying to query information which is not
* directly addressable.
*
* @param entityID the address of the XMPP entity.
* @param node the optional attribute that supplements the 'jid' attribute.
* @return the discovered items.
* @throws XMPPException if the operation failed for some reason.
*/
public DiscoverItems discoverItems(String entityID, String node) throws XMPPException {
// Discover the entity's items
DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET);
disco.setTo(entityID);
disco.setNode(node);
// Create a packet collector to listen for a response.
PacketCollector collector =
connection.createPacketCollector(new PacketIDFilter(disco.getPacketID()));
connection.sendPacket(disco);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
return (DiscoverItems) result;
}
示例5: sendRoomQuery
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
private void sendRoomQuery(String jid) {
DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET);
disco.setTo(jid);
disco.setNode(QUERY_ROOMS);
conn.sendPacket(disco);
}
示例6: discoverItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Get information on the items in the node in standard
* {@link DiscoverItems} format.
*
* @return The item details in {@link DiscoverItems} format
*
* @throws XMPPException
*/
public DiscoverItems discoverItems()
throws XMPPException
{
DiscoverItems items = new DiscoverItems();
items.setTo(to);
items.setNode(getId());
return (DiscoverItems)SyncPacketSend.getReply(con, items);
}
示例7: discoverItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Returns the discovered items of a given XMPP entity addressed by its JID and
* note attribute. Use this message only when trying to query information which is not
* directly addressable.
*
* @param entityID the address of the XMPP entity.
* @param node the optional attribute that supplements the 'jid' attribute.
* @return the discovered items.
* @throws XMPPException if the operation failed for some reason.
*/
public DiscoverItems discoverItems(String entityID, String node) throws XMPPException {
Connection connection = ServiceDiscoveryManager.this.connection.get();
if (connection == null) throw new XMPPException("Connection instance already gc'ed");
// Discover the entity's items
DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET);
disco.setTo(entityID);
disco.setNode(node);
// Create a packet collector to listen for a response.
PacketCollector collector =
connection.createPacketCollector(new PacketIDFilter(disco.getPacketID()));
connection.sendPacket(disco);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
return (DiscoverItems) result;
}
示例8: publishItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Publishes new items to a parent entity and node. The item elements to publish MUST have at
* least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which
* specifies the action being taken for that item. Possible action values are: "update" and
* "remove".
*
* @param entityID the address of the XMPP entity.
* @param node the attribute that supplements the 'jid' attribute.
* @param discoverItems the DiscoveryItems to publish.
* @throws XMPPException if the operation failed for some reason.
*/
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
throws XMPPException {
Connection connection = ServiceDiscoveryManager.this.connection.get();
if (connection == null) throw new XMPPException("Connection instance already gc'ed");
discoverItems.setType(IQ.Type.SET);
discoverItems.setTo(entityID);
discoverItems.setNode(node);
// Create a packet collector to listen for a response.
PacketCollector collector =
connection.createPacketCollector(new PacketIDFilter(discoverItems.getPacketID()));
connection.sendPacket(discoverItems);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
}
示例9: discoverItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Returns the discovered items of a given XMPP entity addressed by its JID
* and note attribute. Use this message only when trying to query
* information which is not directly addressable.
*
* @param entityID
* the address of the XMPP entity.
* @param node
* the attribute that supplements the 'jid' attribute.
* @return the discovered items.
* @throws XMPPException
* if the operation failed for some reason.
*/
public DiscoverItems discoverItems(String entityID, String node)
throws XMPPException {
// Discover the entity's items
DiscoverItems disco = new DiscoverItems();
disco.setType(IQ.Type.GET);
disco.setTo(entityID);
disco.setNode(node);
// Create a packet collector to listen for a response.
PacketCollector collector = connection
.createPacketCollector(new PacketIDFilter(disco.getPacketID()));
connection.sendPacket(disco);
// Wait up to 5 seconds for a result.
IQ result = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from the server.");
}
if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
return (DiscoverItems) result;
}
示例10: searchDiscoItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
private static void searchDiscoItems(final XMPPConnection xmppConnection, final int maxEntries, final String startPoint, final MappedNodes mappedNodes, final int maxDepth, final int maxSearchNodes, final String protocol, final ConcurrentHashMap<String, String> visited) {
final DiscoverItems items = new DiscoverItems();
items.setTo(startPoint);
PacketCollector collector = xmppConnection.createPacketCollector(new PacketIDFilter(items.getPacketID()));
xmppConnection.sendPacket(items);
DiscoverItems result = (DiscoverItems) collector.nextResult(Math.round(SmackConfiguration.getPacketReplyTimeout() * 1.5));
if (result != null) {
final Iterator<DiscoverItems.Item> i = result.getItems();
for (DiscoverItems.Item item = i.hasNext() ? i.next() : null; item != null; item = i.hasNext() ? i.next() : null) {
deepSearch(xmppConnection, maxEntries, item.getEntityID(), mappedNodes, maxDepth, maxSearchNodes, protocol, visited);
}
}
collector.cancel();
}
示例11: discoverNodes
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Get all the nodes that currently exist as a child of the specified
* collection node. If the service does not support collection nodes
* then all nodes will be returned.
*
* To retrieve contents of the root collection node (if it exists),
* or there is no root collection node, pass null as the nodeId.
*
* @param nodeId - The id of the collection node for which the child
* nodes will be returned.
* @return {@link DiscoverItems} representing the existing nodes
*
* @throws XMPPException
*/
public DiscoverItems discoverNodes(String nodeId)
throws XMPPException
{
DiscoverItems items = new DiscoverItems();
if (nodeId != null)
items.setNode(nodeId);
items.setTo(to);
DiscoverItems nodeItems = (DiscoverItems)SyncPacketSend.getReply(con, items);
return nodeItems;
}
示例12: discoverNodes
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Get all the nodes that currently exist as a child of the specified
* collection node. If the service does not support collection nodes then
* all nodes will be returned.
*
* To retrieve contents of the root collection node (if it exists), or there
* is no root collection node, pass null as the nodeId.
*
* @param nodeId
* - The id of the collection node for which the child nodes will
* be returned.
* @return {@link DiscoverItems} representing the existing nodes
*
* @throws XMPPException
*/
public DiscoverItems discoverNodes(String nodeId) throws XMPPException {
DiscoverItems items = new DiscoverItems();
if (nodeId != null)
items.setNode(nodeId);
items.setTo(to);
DiscoverItems nodeItems = (DiscoverItems) SyncPacketSend.getReply(con,
items);
return nodeItems;
}
示例13: discoverItems
import org.jivesoftware.smackx.packet.DiscoverItems; //导入方法依赖的package包/类
/**
* Get information on the items in the node in standard
* {@link DiscoverItems} format.
*
* @return The item details in {@link DiscoverItems} format
*
* @throws XMPPException
*/
public DiscoverItems discoverItems() throws XMPPException {
DiscoverItems items = new DiscoverItems();
items.setTo(to);
items.setNode(getId());
return (DiscoverItems) SyncPacketSend.getReply(con, items);
}