Package org.apache.vysper.xmpp.stanza

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


    public void testUpdatedPresence() throws BindException, EntityFormatException {
        StanzaReceiverRelay receiverRelay = (StanzaReceiverRelay) sessionContext.getServerRuntimeContext().getStanzaRelay();

        // at first, initial presence
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), null, null, null, null, null).build());
        handler.executeCore(initialPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        assertTrue(0 < receiverRelay.getCountDelivered());
        resetRecordedStanzas(); // purge recorded
        assertTrue(0 == receiverRelay.getCountDelivered());
       
        // send update now
        final String showValue = "chatty";
       
        XMPPCoreStanza updatePresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(initiatingUser.getEntityFQ(), null, null, null, showValue, null).build());
        handler.executeCore(updatePresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        // check resource state
        assertEquals(ResourceState.AVAILABLE, getResourceState());

        // 3 presence update broadcasts to same session + 2 presence to subscribers
View Full Code Here


    }
   
    public void processStanza(ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext, Stanza stanza, SessionStateHolder sessionStateHolder) {
        if (stanza == null) throw new RuntimeException("cannot process NULL stanzas");

        XMPPCoreStanza xmppStanza = XMPPCoreStanza.getWrapper(stanza);
        if (xmppStanza == null) throw new RuntimeException("cannot process only: IQ, message or presence");

        StanzaHandler stanzaHandler = handlers.get(xmppStanza);

        if (stanzaHandler == null) {
View Full Code Here

                                                          receivedStanza);
        writeErrorAndClose(sessionContext, errorStanza);
    }

    public void handleWrongFromJID(SessionContext sessionContext, Stanza receivedStanza) {
        XMPPCoreStanza receivedCoreStanza = XMPPCoreStanza.getWrapper(receivedStanza);
        if (receivedCoreStanza == null) {
            handleNotAuthorized(sessionContext, receivedStanza);
            return;
        }
View Full Code Here

        if (!(stanza instanceof XMPPCoreStanza)) {
            stanza = XMPPCoreStanza.getWrapper(stanza);
        }
        if (stanza == null) throw new IllegalArgumentException("cannot coerce into a message, iq or presence stanza");

        XMPPCoreStanza coreStanza = (XMPPCoreStanza) stanza;
        Stanza errorStanza = ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.SERVICE_UNAVAILABLE, coreStanza, StanzaErrorType.CANCEL, "namespace not supported", null, null);
        return new ResponseStanzaContainerImpl(errorStanza);
    }
View Full Code Here

        return true;
    }


    public ResponseStanzaContainer execute(Stanza anyStanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder) {
        XMPPCoreStanza stanza = XMPPCoreStanza.getWrapper(anyStanza);
        if (stanza == null) throw new IllegalArgumentException("can only handle core XMPP stanzas (iq, message, presence)");

        // type="error" is common to all stanza, check here some prerequisites
        Attribute typeAttribute = stanza.getAttribute("type");
        XMPPCoreStanza xmppCoreStanza = XMPPCoreStanza.getWrapper(stanza);
        if (xmppCoreStanza != null && typeAttribute != null)
        {
            String errorDescription = null;
            String type = typeAttribute.getValue();
            if (IQStanzaType.ERROR.value().equals(type)) {
View Full Code Here

        Stanza failureMessageStanza = StanzaBuilder.createMessageStanza(sender, noReceiver, "en", "info").build();
        responseStanzaContainer = messageHandler.execute(failureMessageStanza, senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
        assertNull(receiverQueue.getNext());
        Stanza rejectionStanza = senderQueue.getNext();
        assertNotNull(rejectionStanza);
        XMPPCoreStanza rejectionCoreStanza = XMPPCoreStanza.getWrapper(rejectionStanza);
        assertEquals("error", rejectionCoreStanza.getType());

    }
View Full Code Here

        while (!runnableFuture.isDone()) {
            try { Thread.sleep(SLEEP_INTERVAL); } catch (InterruptedException e) { ; }
        }

        XMPPCoreStanza coreStanza = runnableFuture.get();
        assertNotNull(coreStanza);
       

    }   
View Full Code Here

            }
        }

        @SpecCompliant(spec="draft-ietf-xmpp-3921bis-00", section="8.3.", status= SpecCompliant.ComplianceStatus.IN_PROGRESS, coverage = SpecCompliant.ComplianceCoverage.COMPLETE)
        private RelayResult deliverToBareJID() {
            XMPPCoreStanza xmppStanza = XMPPCoreStanza.getWrapper(stanza);
            if (xmppStanza == null) return new RelayResult(new DeliveryException("unable to deliver stanza which is not IQ, presence or message"));

            if (PresenceStanza.isOfType(stanza)) {
                return relayToAllSessions();
            } else if (MessageStanza.isOfType(stanza)) {
View Full Code Here

            return relayNotPossible();
        }

        @SpecCompliant(spec="draft-ietf-xmpp-3921bis-00", section="8.2.", status= SpecCompliant.ComplianceStatus.IN_PROGRESS, coverage = SpecCompliant.ComplianceCoverage.COMPLETE)
        private RelayResult deliverToFullJID() {
            XMPPCoreStanza xmppStanza = XMPPCoreStanza.getWrapper(stanza);
            if (xmppStanza == null) new RelayResult(new DeliveryException("unable to deliver stanza which is not IQ, presence or message"));

            // all special cases are handled by the inbound handlers!
            if (PresenceStanza.isOfType(stanza)) {
                // TODO cannot deliver presence with type  AVAIL or UNAVAIL: silently ignore
View Full Code Here

     *
     * @param user  User whose Presence Information is to be created
     * @return  Presence Information of the User
     */
    protected PresenceStanza getPresenceStanza(TestUser user) {
        XMPPCoreStanza initialPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(user.getEntityFQ(),
                                                                                                       null, null, null, null, null).build());
        return (PresenceStanza)initialPresence;
    }
View Full Code Here

TOP

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

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.