Package rocks.xmpp.core.stanza.model.client

Examples of rocks.xmpp.core.stanza.model.client.IQ


                "          node='music'\n" +
                "          name='Music from the time of Shakespeare'/>\n" +
                "  </query>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        ItemNode itemNode = iq.getExtension(ItemDiscovery.class);
        Assert.assertNotNull(itemNode);
        Assert.assertEquals(itemNode.getItems().size(), 3);
        Assert.assertEquals(itemNode.getItems().get(0).getJid(), Jid.valueOf("catalog.shakespeare.lit"));
        Assert.assertEquals(itemNode.getItems().get(0).getNode(), "books");
        Assert.assertEquals(itemNode.getItems().get(0).getName(), "Books by and about Shakespeare");
View Full Code Here


                "        <value>http://shakespeare.lit/support.php</value>\n" +
                "      </field>\n" +
                "    </x>\n" +
                "  </query>\n" +
                "</iq>\n";
        IQ iq = unmarshal(xml, IQ.class);
        InfoNode infoDiscovery = iq.getExtension(InfoDiscovery.class);
        Assert.assertNotNull(infoDiscovery);
        Assert.assertEquals(infoDiscovery.getExtensions().size(), 1);
        Assert.assertEquals(infoDiscovery.getExtensions().get(0).getType(), DataForm.Type.RESULT);
    }
View Full Code Here

        });

        xmppSession.addIQListener(new IQListener() {
            @Override
            public void handle(final IQEvent e) {
                final IQ iq = e.getIQ();
                if (e.isIncoming() && isEnabled() && !e.isConsumed() && iq.getType() == IQ.Type.SET) {
                    Rpc rpc = iq.getExtension(Rpc.class);
                    // If there's an incoming RPC
                    if (rpc != null) {
                        synchronized (RpcManager.this) {
                            if (rpcHandler != null) {
                                final Rpc.MethodCall methodCall = rpc.getMethodCall();
                                final List<Value> parameters = new ArrayList<>();
                                for (Value parameter : methodCall.getParameters()) {
                                    parameters.add(parameter);
                                }
                                executorService.execute(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            Value value = rpcHandler.process(iq.getFrom(), methodCall.getMethodName(), parameters);
                                            IQ result = iq.createResult();
                                            result.setExtension(new Rpc(value));
                                            xmppSession.send(result);
                                        } catch (RpcException e1) {
                                            IQ result = iq.createResult();
                                            result.setExtension(new Rpc(new Rpc.MethodResponse.Fault(e1.getFaultCode(), e1.getFaultString())));
                                            xmppSession.send(result);
                                        } catch (Throwable e1) {
                                            logger.log(Level.WARNING, e1.getMessage(), e1);
                                            xmppSession.send(iq.createError(new StanzaError(new InternalServerError())));
                                        }
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#createroom-instant">10.1.2 Creating an Instant Room</a>
     */
    public void createRoom() throws XmppException {
        enter(nick);
        xmppSession.query(new IQ(roomJid, IQ.Type.SET, new MucOwner(new DataForm(DataForm.Type.SUBMIT))));
    }
View Full Code Here

     * @see rocks.xmpp.extensions.muc.model.RoomConfigurationForm
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#createroom-reserved">10.1.3 Creating a Reserved Room</a>
     * @see #submitConfigurationForm(rocks.xmpp.extensions.data.model.DataForm)
     */
    public DataForm getConfigurationForm() throws XmppException {
        IQ result = xmppSession.query(new IQ(roomJid, IQ.Type.GET, new MucOwner()));
        MucOwner mucOwner = result.getExtension(MucOwner.class);
        return mucOwner.getConfigurationForm();
    }
View Full Code Here

        }
        if (!"http://jabber.org/protocol/muc#roomconfig".equals(dataForm.getFormType())) {
            throw new IllegalArgumentException("Data Form is not of type 'http://jabber.org/protocol/muc#roomconfig'");
        }
        MucOwner mucOwner = new MucOwner(dataForm);
        IQ iq = new IQ(roomJid, IQ.Type.SET, mucOwner);
        xmppSession.query(iq);
    }
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the chat service did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#destroyroom">10.9 Destroying a Room</a>
     */
    public void destroy(String reason) throws XmppException {
        MucOwner mucOwner = MucOwner.withDestroy(roomJid, reason);
        IQ iq = new IQ(roomJid, IQ.Type.SET, mucOwner);
        xmppSession.query(iq);
    }
View Full Code Here

                "    </DESC>\n" +
                "    <CLASS><PUBLIC/></CLASS>\n" +
                "  </vCard>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        VCard vCard = iq.getExtension(VCard.class);
        Assert.assertNotNull(vCard);
        Assert.assertEquals(vCard.getFormattedName(), "Peter Saint-Andre");
        Assert.assertNotNull(vCard.getName());
        Assert.assertEquals(vCard.getName().getFamilyName(), "Saint-Andre");
        Assert.assertEquals(vCard.getName().getGivenName(), "Peter");
View Full Code Here

        });

        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) {
                    InfoDiscovery infoDiscovery = iq.getExtension(InfoDiscovery.class);
                    if (infoDiscovery != null) {
                        if (infoDiscovery.getNode() == null) {
                            IQ result = iq.createResult();
                            result.setExtension(new InfoDiscovery(getIdentities(), getFeatures(), getExtensions()));
                            xmppSession.send(result);
                            e.consume();
                        } else {
                            InfoNode infoNode = infoNodeMap.get(infoDiscovery.getNode());
                            if (infoNode != null) {
                                IQ result = iq.createResult();
                                result.setExtension(new InfoDiscovery(infoNode.getNode(), infoNode.getIdentities(), infoNode.getFeatures(), infoNode.getExtensions()));
                                xmppSession.send(result);
                                e.consume();
                            } else {
                                xmppSession.send(iq.createError(new StanzaError(new ItemNotFound())));
                                e.consume();
                            }
                        }
                    } else {
                        ItemDiscovery itemDiscovery = iq.getExtension(ItemDiscovery.class);
                        if (itemDiscovery != null) {
                            if (itemDiscovery.getNode() == null) {
                                IQ result = iq.createResult();
                                result.setExtension(new ItemDiscovery(items));
                                xmppSession.send(result);
                                e.consume();
                            } else {
                                ItemNode itemNode = itemNodeMap.get(itemDiscovery.getNode());
                                if (itemNode != null) {
                                    IQ result = iq.createResult();
                                    result.setExtension(new ItemDiscovery(itemNode.getNode(), items));
                                    xmppSession.send(result);
                                    e.consume();
                                } else {
                                    xmppSession.send(iq.createError(new StanzaError(new ItemNotFound())));
                                    e.consume();
View Full Code Here

     * @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.
     * @see #discoverInformation(rocks.xmpp.core.Jid)
     */
    public InfoNode discoverInformation(Jid jid, String node) throws XmppException {
        IQ iq = new IQ(jid, IQ.Type.GET, new InfoDiscovery(node));
        IQ result = xmppSession.query(iq);
        return result.getExtension(InfoDiscovery.class);
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.core.stanza.model.client.IQ

Copyright © 2018 www.massapicom. 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.