Package org.apache.vysper.xmpp.stanza

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


        if (isOutboundStanza) {
            // this is an outbound subscription
            // request/approval/cancellation/unsubscription
            // stamp it with the bare JID of the user
            Entity user = initiatingEntity;
            PresenceStanza stampedStanza = buildPresenceStanza(user.getBareJID(), presenceStanza.getTo().getBareJID(),
                    presenceStanza.getPresenceType(), null);

            switch (type) {

            case SUBSCRIBE:
View Full Code Here


        // contact
        List<String> resources = registry.getAvailableResources(user);
        for (String resource : resources) {
            Entity userResource = new EntityImpl(user, resource);

            PresenceStanza cachedPresenceStanza = sessionContext.getServerRuntimeContext().getPresenceCache().get(
                    userResource);
            if (cachedPresenceStanza == null)
                continue;

            PresenceStanza sendoutPresence = buildPresenceStanza(userResource, contactBareJid, null,
                    cachedPresenceStanza.getInnerElements());
            relayStanza(contact, sendoutPresence, sessionContext);
        }
    }
View Full Code Here

        }

        // check whether user already has a subscription to contact
        if (result == ALREADY_SET) {
            Entity receiver = contact.getBareJID();
            PresenceStanza alreadySubscribedResponse = buildPresenceStanza(userBareJid, receiver, SUBSCRIBED, null);
            relayStanza(receiver, alreadySubscribedResponse, sessionContext);
            return null;
        }

        // user exists and doesn't have a subscription, so...
View Full Code Here

            // presence probes must happen on resource level!
            relayStanza(contact, buildPresenceStanza(user, contact, UNSUBSCRIBED, null), sessionContext);
            return null;
        }

        PresenceStanza latestPresenceStanza = retrieveLatestPresence(sessionContext, user);
        if (latestPresenceStanza == null) {
            // we have no current presence info
            relayStanza(contact, buildPresenceStanza(user, contact, UNAVAILABLE, null), sessionContext);
            return null;
        }

        // return current presence as probing result
        relayStanza(contact, buildPresenceStanza(user, contact, null, latestPresenceStanza.getInnerElements()),
                sessionContext);

        return null;
    }
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

        if (isOutboundStanza) {
      // this is an outbound subscription
      // request/approval/cancellation/unsubscription
      // stamp it with the bare JID of the user
      Entity user = initiatingEntity;
      PresenceStanza stampedStanza = buildPresenceStanza(user.getBareJID(),
                    presenceStanza.getTo().getBareJID(), presenceStanza.getPresenceType(), null);

            switch (type) {

                case SUBSCRIBE:
View Full Code Here

    // contact
        List<String> resources = registry.getAvailableResources(user);
    for (String resource : resources) {
      Entity userResource = new EntityImpl(user, resource);

            PresenceStanza cachedPresenceStanza = sessionContext.getServerRuntimeContext().getPresenceCache().get(userResource);
            if (cachedPresenceStanza == null) continue;

            PresenceStanza sendoutPresence = buildPresenceStanza(userResource, contactBareJid, null, cachedPresenceStanza.getInnerElements());
            relayStanza(contact, sendoutPresence, sessionContext);
    }
  }
View Full Code Here

        }

        // check whether user already has a subscription to contact
        if (result == ALREADY_SET) {
            Entity receiver = contact.getBareJID();
            PresenceStanza alreadySubscribedResponse = buildPresenceStanza(userBareJid, receiver, SUBSCRIBED, null);
            relayStanza(receiver, alreadySubscribedResponse, sessionContext);
            return null;
        }

        // user exists and doesn't have a subscription, so...
View Full Code Here

            // presence probes must happen on resource level!
            relayStanza(contact, buildPresenceStanza(user, contact, UNSUBSCRIBED, null), sessionContext);
            return null;
        }

        PresenceStanza latestPresenceStanza = retrieveLatestPresence(sessionContext, user);
        if (latestPresenceStanza == null) {
            // we have no current presence info
            relayStanza(contact, buildPresenceStanza(user, contact, UNAVAILABLE, null), sessionContext);
            return null;
        }

        // return current presence as probing result
        relayStanza(contact, buildPresenceStanza(user, contact, null, latestPresenceStanza.getInnerElements()), sessionContext);

    return null;
  }
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.