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

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


        // For direct invitations:
        // If the contact declines the invitation, it shall silently discard the invitation.

        // Therefore only decline mediated invitations.
        if (mediated) {
            Message message = new Message(room);
            message.getExtensions().add(new Decline(inviter, reason));
            xmppSession.send(message);
        }
    }
View Full Code Here


                final ChatSession chatSession = chatSessionEvent.getChatSession();
                chatSession.addMessageListener(new MessageListener() {
                    @Override
                    public void handle(MessageEvent e) {
                        if (isEnabled()) {
                            Message message = e.getMessage();
                            if (!e.isIncoming()) {
                                // In the absence of explicit discovery or negotiation, the User MAY implicitly request and discover the use of chat state notifications in a one-to-one chat session by adhering to the following business rules:
                                // 1. If the User desires chat state notifications, the message(s) that it sends to the Contact before receiving a reply MUST contain a chat state notification extension, which SHOULD be <active/>.
                                if (!contactSupportsChatStateNotifications.containsKey(message.getTo()) && contactSupportsChatStateNotifications.get(message.getTo())
                                        && message.getExtension(Active.class) == null
                                        && message.getExtension(Composing.class) == null
                                        && message.getExtension(Gone.class) == null
                                        && message.getExtension(Inactive.class) == null
                                        && message.getExtension(Paused.class) == null) {

                                    message.getExtensions().add(new Active());
                                    notifyChatStateListeners(chatSession, ChatState.ACTIVE, !e.isIncoming());
                                }
                            }

                            if (message.getExtension(Active.class) != null) {
                                notifyChatStateListeners(chatSession, ChatState.ACTIVE, !e.isIncoming());
                            } else if (message.getExtension(Composing.class) != null) {
                                notifyChatStateListeners(chatSession, ChatState.COMPOSING, !e.isIncoming());
                            } else if (message.getExtension(Gone.class) != null) {
                                notifyChatStateListeners(chatSession, ChatState.GONE, !e.isIncoming());
                                //connection.getChatManager().destroyChatSession(chatSession);
                            } else if (message.getExtension(Inactive.class) != null) {
                                notifyChatStateListeners(chatSession, ChatState.INACTIVE, !e.isIncoming());
                            } else if (message.getExtension(Paused.class) != null) {
                                notifyChatStateListeners(chatSession, ChatState.PAUSED, !e.isIncoming());
                            }
                        }
                    }
                });
View Full Code Here

        // Listen for incoming invitations.
        xmppSession.addMessageListener(new MessageListener() {
            @Override
            public void handle(MessageEvent e) {
                if (e.isIncoming()) {
                    Message message = e.getMessage();
                    // Check, if the message contains a mediated invitation.
                    MucUser mucUser = message.getExtension(MucUser.class);
                    if (mucUser != null) {
                        for (Invite invite : mucUser.getInvites()) {
                            notifyListeners(new InvitationEvent(MultiUserChatManager.this, xmppSession, invite.getFrom(), message.getFrom(), invite.getReason(), mucUser.getPassword(), invite.isContinue(), invite.getThread(), true));
                        }
                    } else {
                        // Check, if the message contains a direct invitation.
                        DirectInvitation directInvitation = message.getExtension(DirectInvitation.class);
                        if (directInvitation != null) {
                            notifyListeners(new InvitationEvent(MultiUserChatManager.this, xmppSession, message.getFrom(), directInvitation.getRoomAddress(), directInvitation.getReason(), directInvitation.getPassword(), directInvitation.isContinue(), directInvitation.getThread(), false));
                        }
                    }
                }
            }
        });
View Full Code Here

                "     password='cauldronburn'\n" +
                "     reason='Hey Hecate, this is the place for all good witches!'\n" +
                "     thread='e0ffe42b28561960c6b12b944a092794b9683a38'/>\n" +
                "</message>";

        Message message = unmarshal(xml, Message.class);
        DirectInvitation directInvitation = message.getExtension(DirectInvitation.class);
        Assert.assertNotNull(directInvitation);
        Assert.assertTrue(directInvitation.isContinue());
        Assert.assertEquals(directInvitation.getRoomAddress(), Jid.valueOf("darkcave@macbeth.shakespeare.lit"));
        Assert.assertEquals(directInvitation.getPassword(), "cauldronburn");
        Assert.assertEquals(directInvitation.getReason(), "Hey Hecate, this is the place for all good witches!");
View Full Code Here

                "     <error type='wait'>\n" +
                "       <remote-server-timeout\n" +
                "           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message.getError());
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.WAIT);
        Assert.assertTrue(message.getError().getCondition() instanceof RemoteServerTimeout);
    }
View Full Code Here

                "     <error type='cancel'>\n" +
                "       <service-unavailable\n" +
                "           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message.getError());
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.CANCEL);
        Assert.assertTrue(message.getError().getCondition() instanceof ServiceUnavailable);
    }
View Full Code Here

                "     <error type='auth'>\n" +
                "       <subscription-required\n" +
                "           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message.getError());
        Assert.assertEquals(message.getType(), Message.Type.ERROR);
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.AUTH);
        Assert.assertTrue(message.getError().getCondition() instanceof SubscriptionRequired);
    }
View Full Code Here

                "               condition='deliver'\n" +
                "               value='stored'/>\n" +
                "       </failed-rules>\n" +
                "     </error>\n" +
                "   </message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message.getError());
        Assert.assertEquals(message.getType(), Message.Type.ERROR);
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.MODIFY);
        Assert.assertTrue(message.getError().getCondition() instanceof UndefinedCondition);
    }
View Full Code Here

                "    <text xml:lang='en'\n" +
                "          xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>[ ... application-specific information ... ]</text>\n" +
                "    <too-many-parameters xmlns='http://example.org/ns'/>\n" +
                "  </error>\n" +
                "</message>";
        Message message = unmarshal(xml, Message.class);
        Assert.assertNotNull(message.getError());
        Assert.assertTrue(message.getError().getCondition() instanceof UndefinedCondition);
        Assert.assertEquals(message.getError().getType(), StanzaError.Type.MODIFY);
        Assert.assertEquals(message.getError().getText(), "[ ... application-specific information ... ]");
        Assert.assertEquals(message.getError().getLanguage(), "en");
        Assert.assertEquals(message.getError().getBy().toString(), "romeo@example.net/foo");
        Assert.assertTrue(message.getError().getExtension() instanceof Element);
        Assert.assertEquals(((Element) message.getError().getExtension()).getTagName(), "too-many-parameters");
    }
View Full Code Here

                "    <rule condition='expire-at'\n" +
                "          action='drop'\n" +
                "          value='2004-01-01T00:00:00Z'/>\n" +
                "  </amp>\n" +
                "</message>\n";
        Message message = unmarshal(xml, Message.class);
        AdvancedMessageProcessing amp = message.getExtension(AdvancedMessageProcessing.class);
        Assert.assertNotNull(amp);
        Assert.assertTrue(amp.isPerHop());
        Assert.assertEquals(amp.getStatus(), Rule.Action.ALERT);
        Assert.assertEquals(amp.getFrom(), Jid.valueOf("bernardo@hamlet.lit/elsinore"));
        Assert.assertEquals(amp.getRules().size(), 1);
View Full Code Here

TOP

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

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.