Examples of Reachability


Examples of rocks.xmpp.extensions.reach.model.Reachability

                    }
                } else {
                    if (presence.isAvailable() && presence.getTo() == null) {
                        synchronized (addresses) {
                            if (!addresses.isEmpty()) {
                                presence.getExtensions().add(new Reachability(new ArrayList<>(addresses)));
                            }
                        }
                    }
                }
            }
        });

        // A user MAY send reachability addresses in an XMPP <message/> stanza.
        xmppSession.addMessageListener(new MessageListener() {
            @Override
            public void handle(MessageEvent e) {
                if (e.isIncoming()) {
                    checkStanzaForReachabilityAndNotify(e.getMessage());
                }
            }
        });

        // In addition, a contact MAY request a user's reachability addresses in an XMPP <iq/> stanza of type "get"
        xmppSession.addIQListener(new IQListener() {
            @Override
            public void handle(IQEvent e) {
                IQ iq = e.getIQ();
                if (e.isIncoming() && isEnabled() && !e.isConsumed() && iq.getType() == IQ.Type.GET && iq.getExtension(Reachability.class) != null) {
                    IQ result = iq.createResult();
                    result.setExtension(new Reachability(new ArrayList<>(addresses)));
                    xmppSession.send(result);
                    e.consume();
                }
            }
        });
View Full Code Here

Examples of rocks.xmpp.extensions.reach.model.Reachability

    public List<Address> getReachabilityAddresses() {
        return addresses;
    }

    private boolean checkStanzaForReachabilityAndNotify(Stanza stanza) {
        Reachability reachability = stanza.getExtension(Reachability.class);
        if (stanza.getFrom() != null) {
            Jid contact = stanza.getFrom().asBareJid();
            if (reachability != null) {
                synchronized (reachabilities) {
                    List<Address> oldReachabilityAddresses = reachabilities.get(contact);
                    if (oldReachabilityAddresses == null || !oldReachabilityAddresses.equals(reachability.getAddresses())) {
                        reachabilities.put(contact, reachability.getAddresses());
                        notifyReachabilityListeners(contact, reachability.getAddresses());
                    }
                }
            }
        }
        return reachability != null;
View Full Code Here

Examples of rocks.xmpp.extensions.reach.model.Reachability

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the entity returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     */
    public List<Address> requestReachabilityAddresses(Jid contact) throws XmppException {
        // In addition, a contact MAY request a user's reachability addresses in an XMPP <iq/> stanza of type "get".
        IQ result = xmppSession.query(new IQ(contact, IQ.Type.GET, new Reachability()));
        Reachability reachability = result.getExtension(Reachability.class);
        if (reachability != null) {
            return reachability.getAddresses();
        }
        return null;
    }
View Full Code Here

Examples of rocks.xmpp.extensions.reach.model.Reachability

                "          </addr>\n" +
                "          <addr uri='sip:room123@example.com'>\n" +
                "            <desc xml:lang='en'>In-room video system</desc>\n" +
                "          </addr>\n" +
                "        </reach>\n";
        Reachability reachability = unmarshal(xml, Reachability.class);
        Assert.assertNotNull(reachability);
        Assert.assertEquals(reachability.getAddresses().size(), 2);
        Assert.assertEquals(reachability.getAddresses().get(0).getUri(), URI.create("tel:+1-303-555-1212"));
        Assert.assertEquals(reachability.getAddresses().get(0).getDescriptions().size(), 1);
        Assert.assertEquals(reachability.getAddresses().get(0).getDescriptions().get(0).getValue(), "Conference room phone");
        Assert.assertEquals(reachability.getAddresses().get(0).getDescriptions().get(0).getLanguage(), "en");
        Assert.assertEquals(reachability.getAddresses().get(1).getUri(), URI.create("sip:room123@example.com"));
        Assert.assertEquals(reachability.getAddresses().get(1).getDescriptions().get(0).getValue(), "In-room video system");
        Assert.assertEquals(reachability.getAddresses().get(1).getDescriptions().get(0).getLanguage(), "en");
    }
View Full Code Here

Examples of rocks.xmpp.extensions.reach.model.Reachability

    }

    @Test
    public void testReachabilityEquality() {

        Reachability reachability1 = new Reachability(Arrays.asList(new Address(URI.create("sip:room123@example.com"), new Address.Description("In-room video system", "en"))));
        Reachability reachability2 = new Reachability(Arrays.asList(new Address(URI.create("sip:room123@example.com"), new Address.Description("In-room video system", "en"))));

        Assert.assertEquals(reachability1, reachability2);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.