Package org.apache.vysper.xmpp.stanza

Examples of org.apache.vysper.xmpp.stanza.MessageStanza


        stanza = occupant1Queue.getNext();
        // here we get the message history
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        MessageStanza msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body2", msgStanza.getBody(null));

        stanza = occupant1Queue.getNext();
        // first stanza should be room presence
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body3", msgStanza.getBody(null));

        // we only requested two messages
        assertNull(occupant1Queue.getNext());
    }
View Full Code Here


                        "unable to deliver stanza which is not IQ, presence or message"));

            if (PresenceStanza.isOfType(stanza)) {
                return relayToAllSessions();
            } else if (MessageStanza.isOfType(stanza)) {
                MessageStanza messageStanza = (MessageStanza) xmppStanza;
                MessageStanzaType messageStanzaType = messageStanza.getMessageType();
                switch (messageStanzaType) {
                case CHAT:
                case NORMAL:
                    return serverRuntimeContext.getServerFeatures().isDeliveringMessageToHighestPriorityResourcesOnly() ? relayToBestSessions(false)
                            : relayToAllSessions(0);
View Full Code Here

                // TODO cannot deliver presence with type  AVAIL or UNAVAIL: silently ignore
                // TODO cannot deliver presence with type  SUBSCRIBE: see 3921bis section 3.1.3
                // TODO cannot deliver presence with type  (UN)SUBSCRIBED, UNSUBSCRIBE: silently ignore
                return relayToBestSessions(false);
            } else if (MessageStanza.isOfType(stanza)) {
                MessageStanza messageStanza = (MessageStanza) xmppStanza;
                MessageStanzaType messageStanzaType = messageStanza.getMessageType();
                boolean fallbackToBareJIDAllowed = messageStanzaType == MessageStanzaType.CHAT
                        || messageStanzaType == MessageStanzaType.HEADLINE
                        || messageStanzaType == MessageStanzaType.NORMAL;
                // TODO cannot deliver ERROR: silently ignore
                // TODO cannot deliver GROUPCHAT: service n/a
View Full Code Here

    }

    @Override
    protected Stanza executeCore(XMPPCoreStanza coreStanza, ServerRuntimeContext serverRuntimeContext,
            boolean isOutboundStanza, SessionContext sessionContext) {
        MessageStanza stanza = (MessageStanza) coreStanza;

        return executeMessageLogic(stanza, serverRuntimeContext, sessionContext);
    }
View Full Code Here

  public void receive(Stanza stanza) {
    // according to XEP-0160 only certain stanzas should be stored
    boolean store = false;
    logger.debug("Received Stanza for offline storage:" +stanza.getClass().getSimpleName());
    if (stanza instanceof MessageStanza) {
      MessageStanza messageStanza = (MessageStanza) stanza;
      MessageStanzaType type = messageStanza.getMessageType();
      switch (type) {
                case NORMAL:
                case CHAT:
                    store = true;
                    break;
View Full Code Here

        stanza = occupant1Queue.getNext();
        // here we get the message history
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        MessageStanza msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body2", msgStanza.getBody(null));

        stanza = occupant1Queue.getNext();
        // first stanza should be room presence
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body3", msgStanza.getBody(null));

        // we only requested two messages
        assertNull(occupant1Queue.getNext());
    }
View Full Code Here

        strategy.process(stanza, Arrays.asList((DeliveryException)new RemoteServerNotFoundException(ERROR_TEXT)));
       
        Iterator<Triple> triples = relay.iterator();
        Triple triple = triples.next();
        Assert.assertEquals(FROM, triple.getEntity());
        MessageStanza errorStanza = (MessageStanza) XMPPCoreStanza.getWrapper(triple.getStanza());
        Assert.assertEquals("error", errorStanza.getType());
        Assert.assertEquals(FROM, errorStanza.getTo());
        Assert.assertEquals(SERVER, errorStanza.getFrom());
       
        XMLElement errorElm = errorStanza.getSingleInnerElementsNamed("error", NamespaceURIs.JABBER_CLIENT);
        Assert.assertEquals("cancel", errorElm.getAttributeValue("type"));

        Assert.assertNotNull(errorElm.getSingleInnerElementsNamed("remote-server-not-found", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS));

        XMLElement textElm = errorElm.getSingleInnerElementsNamed("text", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS);
View Full Code Here

        strategy.process(stanza, null);
       
        Iterator<Triple> triples = relay.iterator();
        Triple triple = triples.next();
        Assert.assertEquals(FROM, triple.getEntity());
        MessageStanza errorStanza = (MessageStanza) XMPPCoreStanza.getWrapper(triple.getStanza());
        Assert.assertEquals("error", errorStanza.getType());
        Assert.assertEquals(FROM, errorStanza.getTo());
        Assert.assertEquals(SERVER, errorStanza.getFrom());
       
        XMLElement errorElm = errorStanza.getSingleInnerElementsNamed("error", NamespaceURIs.JABBER_CLIENT);
        Assert.assertEquals("cancel", errorElm.getAttributeValue("type"));
        Assert.assertNotNull(errorElm.getSingleInnerElementsNamed("service-unavailable", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS));

        Assert.assertNotNull(errorElm.getSingleInnerElementsNamed("text", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS));
       
View Full Code Here

    }

    protected void assertMessageStanza(Entity from, Entity to, String type, String expectedBody,
            String expectedSubject, X expectedX, Stanza stanza) throws XMLSemanticError {
        assertNotNull(stanza);
        MessageStanza msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);

        assertEquals(from, stanza.getFrom());
        assertEquals(to, stanza.getTo());
        if (type != null) {
            assertEquals(type, msgStanza.getType());
        }

        assertEquals(expectedBody, msgStanza.getBody(null));
        assertEquals(expectedSubject, msgStanza.getSubject(null));

        if (expectedX != null) {
            X actualX = X.fromStanza(stanza);
            assertEquals(expectedX, actualX);
        }
View Full Code Here

        assertMessageStanza(from, to, type, Arrays.asList(expectedInner), actual);
    }
   
    protected void assertMessageStanza(Entity from, Entity to, String type, List<XMLElement> expectedInner, Stanza actual) throws XMLSemanticError {
        assertNotNull(actual);
        MessageStanza msgStanza = (MessageStanza) MessageStanza.getWrapper(actual);

        assertEquals(from, actual.getFrom());
        assertEquals(to, actual.getTo());
        if (type != null) {
            assertEquals(type, msgStanza.getType());
        }

        assertEquals("Length of inner elements", expectedInner.size(), actual.getInnerElements().size());
       
        for(int i = 0; i<expectedInner.size(); i++) {
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.stanza.MessageStanza

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.