/** * Returns the discovered information 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 information. * @throws XMPPException if the operation failed for some reason. */ public DiscoverInfo discoverInfo(String entityID, String node) throws XMPPException { // Discover the entity's info DiscoverInfo disco = new DiscoverInfo(); 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 (DiscoverInfo) result; }
/** * Get a DiscoverInfo for the current entity caps node. * * @return a DiscoverInfo for the current entity caps node */ public DiscoverInfo getOwnDiscoverInfo() { DiscoverInfo di = new DiscoverInfo(); di.setType(IQ.Type.RESULT); di.setNode(capsManager.getNode() + "#" + getEntityCapsVersion()); // Add discover info addDiscoverInfoTo(di); return di; }