示例#1
0
  /**
   * 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.
   *
   * @see <a href="http://xmpp.org/extensions/xep-0030.html#info-basic">XEP-30 Basic Protocol</a>
   * @see <a href="http://xmpp.org/extensions/xep-0030.html#info-nodes">XEP-30 Info Nodes</a>
   * @param entityID the address of the XMPP entity.
   * @param node the optional attribute that supplements the 'jid' attribute.
   * @return the discovered information.
   * @throws XMPPErrorException if the operation failed for some reason.
   * @throws NoResponseException if there was no response from the server.
   * @throws NotConnectedException
   */
  public DiscoverInfo discoverInfo(String entityID, String node)
      throws NoResponseException, XMPPErrorException, NotConnectedException {
    // Discover the entity's info
    DiscoverInfo disco = new DiscoverInfo();
    disco.setType(IQ.Type.get);
    disco.setTo(entityID);
    disco.setNode(node);

    Packet result = connection().createPacketCollectorAndSend(disco).nextResultOrThrow();

    return (DiscoverInfo) result;
  }
  /**
   * 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.
   *
   * @see <a href="http://xmpp.org/extensions/xep-0030.html#info-basic">XEP-30 Basic Protocol</a>
   * @see <a href="http://xmpp.org/extensions/xep-0030.html#info-nodes">XEP-30 Info Nodes</a>
   * @param entityID the address of the XMPP entity.
   * @param node the optional 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 {
    Connection connection = ServiceDiscoveryManager.this.connection.get();
    if (connection == null) throw new XMPPException("Connection instance already gc'ed");

    // Discover the entity's info
    DiscoverInfo disco = new DiscoverInfo();
    disco.setType(IQ.Type.GET);
    disco.setTo(entityID);
    disco.setNode(node);

    Packet result = connection.createPacketCollectorAndSend(disco).nextResultOrThrow();

    return (DiscoverInfo) result;
  }