Search in sources :

Example 1 with IoTMine

use of org.jivesoftware.smackx.iot.discovery.element.IoTMine in project Smack by igniterealtime.

the class IoTDiscoveryManager method claimThing.

/**
     * Claim a thing by providing a collection of meta tags. If the claim was successful, then a {@link IoTClaimed}
     * instance will be returned, which contains the XMPP address of the thing. Use {@link IoTClaimed#getJid()} to
     * retrieve this address.
     *
     * @param registry the registry use to claim the thing.
     * @param metaTags a collection of meta tags used to identify the thing.
     * @param publicThing if this is a public thing.
     * @return a {@link IoTClaimed} if successful.
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public IoTClaimed claimThing(Jid registry, Collection<Tag> metaTags, boolean publicThing) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    interactWithRegistry(registry);
    IoTMine iotMine = new IoTMine(metaTags, publicThing);
    iotMine.setTo(registry);
    IoTClaimed iotClaimed = connection().createStanzaCollectorAndSend(iotMine).nextResultOrThrow();
    // The 'jid' attribute of the <claimed/> response now represents the XMPP address of the thing we just successfully claimed.
    Jid thing = iotClaimed.getJid();
    IoTProvisioningManager.getInstanceFor(connection()).sendFriendshipRequest(thing.asBareJid());
    return iotClaimed;
}
Also used : IoTMine(org.jivesoftware.smackx.iot.discovery.element.IoTMine) Jid(org.jxmpp.jid.Jid) BareJid(org.jxmpp.jid.BareJid) IoTClaimed(org.jivesoftware.smackx.iot.discovery.element.IoTClaimed)

Aggregations

IoTClaimed (org.jivesoftware.smackx.iot.discovery.element.IoTClaimed)1 IoTMine (org.jivesoftware.smackx.iot.discovery.element.IoTMine)1 BareJid (org.jxmpp.jid.BareJid)1 Jid (org.jxmpp.jid.Jid)1