Package org.apache.vysper.xmpp.stanza

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


    }

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

        boolean subscriptionRelated = isSubscriptionType(presenceStanza.getPresenceType());

        RosterManager rosterManager = RosterManagerUtils.getRosterInstance(serverRuntimeContext, sessionContext);

        if (!subscriptionRelated)
            return AVAILABILITY_HANDLER.executeCorePresence(serverRuntimeContext, isOutboundStanza, sessionContext,
View Full Code Here


        return entry.getPresenceStanza();
    }

    public PresenceStanza getForBareJID(Entity entity) throws PresenceCachingException {
        // TODO this is naive and not optimized. the whole key set is traversed every time
        PresenceStanza latest = null;
        for (Entity key : presenceMap.keySet()) {
            if (key.getBareJID().equals(entity)) {
                latest = presenceMap.get(key).getPresenceStanza(); // this is the latest until we find a newer one
            }
        }
View Full Code Here

   
    private void assertPresenceStanza(Stanza stanza, Entity expectedFrom, Entity expectedTo, String expectedShow,
            String expectedStatus,
            Item expectedItem) throws XMLSemanticError, Exception {

        PresenceStanza presenceStanza = (PresenceStanza) PresenceStanza.getWrapper(stanza);
        assertNotNull(stanza);
        assertEquals(expectedFrom, stanza.getFrom());
        assertEquals(expectedTo, stanza.getTo());
        assertEquals(expectedShow, presenceStanza.getShow());
        assertEquals(expectedStatus, presenceStanza.getStatus(null));
       
        XMLElement xElm = stanza.getSingleInnerElementsNamed("x");
        assertEquals(NamespaceURIs.XEP0045_MUC_USER, xElm.getNamespaceURI());
       
        List<XMLElement> innerElements = xElm.getInnerElements();
View Full Code Here

        return firstInnerElement.getVerifier().namespacePresent(namespace);
    }

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

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

        SessionStateHolder sessionStateHolder = new SessionStateHolder();
        sessionStateHolder.setState(SessionState.AUTHENTICATED);

        // pres 1
        XMPPCoreStanza initialPresence1 = sendInitialPresence(sessionStateHolder, initiatingUser);
        PresenceStanza presenceStanza1 = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1, presenceStanza1);
        assertSame(initialPresence1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));

        // pres 2, same user
        XMPPCoreStanza initialPresence2 = sendInitialPresence(sessionStateHolder, anotherInterestedUser);
        PresenceStanza presenceStanza2 = getCache().get(anotherInterestedUser.getEntityFQ());
        assertSame(initialPresence2, presenceStanza2);
        assertSame(initialPresence2, getCache().getForBareJID(anotherInterestedUser.getEntity().getBareJID()));

        // re-retrieve the pres 1, still there
        PresenceStanza presenceStanza1_again = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1, presenceStanza1_again);
        assertSame(initialPresence2, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));

        // replace pres 1
        XMPPCoreStanza initialPresence1_1 = sendInitialPresence(sessionStateHolder, initiatingUser);
        PresenceStanza presenceStanza1_1 = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1_1, presenceStanza1_1);
        assertSame(initialPresence1_1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));
       
    }
View Full Code Here

    }

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

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

        assertEquals(map.iterator().next(), unrelatedUser.getEntityFQ());

        Stanza directedPresence = unrelatedUser.getNextStanza();
        assertNotNull(directedPresence);
        assertTrue(PresenceStanza.isOfType(directedPresence)); // is presence
        PresenceStanza presenceStanza = new PresenceStanza(directedPresence);
        assertEquals(initiatingUser.getEntityFQ(), presenceStanza.getFrom());

        resetRecordedStanzas(); // purge recorded

        // directed unavailable presence
        XMPPCoreStanza directedUnvailPresence = XMPPCoreStanza.getWrapper(StanzaBuilder.createPresenceStanza(
                initiatingUser.getEntityFQ(), unrelatedUser.getEntityFQ(), null, PresenceStanzaType.UNAVAILABLE, null,
                null).build());
        handler.executeCore(directedUnvailPresence, sessionContext.getServerRuntimeContext(), true, sessionContext);
        assertTrue(0 < receiverRelay.getCountDelivered());

        // directed presence has been recorded internally
        map = (Set<Entity>) sessionContext.getAttribute("DIRECTED_PRESENCE_MAP_" + initiatingUser.getBoundResourceId());
        assertTrue(map.size() == 0);
        ResourceState resourceState = sessionContext.getServerRuntimeContext().getResourceRegistry().getResourceState(
                initiatingUser.getBoundResourceId());
        assertTrue(ResourceState.isAvailable(resourceState));

        Stanza directedUnavailPresence = unrelatedUser.getNextStanza();
        assertNotNull(directedUnavailPresence);
        assertTrue(PresenceStanza.isOfType(directedUnavailPresence)); // is presence
        presenceStanza = new PresenceStanza(directedUnavailPresence);
        assertEquals(initiatingUser.getEntityFQ(), presenceStanza.getFrom());
        assertEquals(PresenceStanzaType.UNAVAILABLE, presenceStanza.getPresenceType());

    }
View Full Code Here

        assertEquals(0, map.size());

        Stanza directedUnavailPresence = unrelatedUser.getNextStanza();
        assertNotNull(directedUnavailPresence);
        assertTrue(PresenceStanza.isOfType(directedUnavailPresence)); // is presence
        PresenceStanza presenceStanza = new PresenceStanza(directedUnavailPresence);
        assertEquals(initiatingUser.getEntityFQ(), presenceStanza.getFrom());
        assertEquals(PresenceStanzaType.UNAVAILABLE, presenceStanza.getPresenceType());

    }
View Full Code Here

        SessionStateHolder sessionStateHolder = new SessionStateHolder();
        sessionStateHolder.setState(SessionState.AUTHENTICATED);

        // pres 1
        XMPPCoreStanza initialPresence1 = sendInitialPresence(sessionStateHolder, initiatingUser);
        PresenceStanza presenceStanza1 = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1, presenceStanza1);
        assertSame(initialPresence1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));

        // pres 2, same user
        XMPPCoreStanza initialPresence2 = sendInitialPresence(sessionStateHolder, anotherInterestedUser);
        PresenceStanza presenceStanza2 = getCache().get(anotherInterestedUser.getEntityFQ());
        assertSame(initialPresence2, presenceStanza2);
        assertSame(initialPresence2, getCache().getForBareJID(anotherInterestedUser.getEntity().getBareJID()));

        // re-retrieve the pres 1, still there
        PresenceStanza presenceStanza1_again = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1, presenceStanza1_again);
        assertSame(initialPresence2, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));

        // replace pres 1
        XMPPCoreStanza initialPresence1_1 = sendInitialPresence(sessionStateHolder, initiatingUser);
        PresenceStanza presenceStanza1_1 = getCache().get(initiatingUser.getEntityFQ());
        assertSame(initialPresence1_1, presenceStanza1_1);
        assertSame(initialPresence1_1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));

    }
View Full Code Here

        return entry.getPresenceStanza();
    }

    public PresenceStanza getForBareJID(Entity entity) throws PresenceCachingException {
        // TODO this is naive and not optimized. the whole key set is traversed every time
        PresenceStanza latest = null;
        for (Entity key : presenceMap.keySet()) {
            if (key.getBareJID().equals(entity)) {
                latest = presenceMap.get(key).getPresenceStanza(); // this is the latest until we find a newer one
            }
        }
View Full Code Here

TOP

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

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.