Package org.apache.vysper.xmpp.stanza

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


                }
            } else if (deliveryException instanceof NoSuchLocalUserException) {
                // RFC3921bis#8.1: message and IQ must return service unavailable
                stanzaErrorCondition = StanzaErrorCondition.SERVICE_UNAVAILABLE;
                if (failedCoreStanza instanceof PresenceStanza) {
                    final PresenceStanzaType presenceStanzaType = ((PresenceStanza) failedCoreStanza).getPresenceType();
                    if (presenceStanzaType == null ||
                            presenceStanzaType == SUBSCRIBED ||
                            presenceStanzaType == UNSUBSCRIBE ||
                            presenceStanzaType == UNSUBSCRIBED ||
                            presenceStanzaType == UNAVAILABLE ||
View Full Code Here


        // error if the from attribute is not present.
        Entity initiatingEntity = sessionContext == null ? null : sessionContext.getInitiatingEntity();
        XMPPCoreStanzaVerifier verifier = presenceStanza.getCoreVerifier();
        ResourceRegistry registry = serverRuntimeContext.getResourceRegistry();

        PresenceStanzaType type = presenceStanza.getPresenceType();

        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:
                // RFC3921bis-04#3.1.2
                // user requests subsription to contact
                handleOutboundSubscriptionRequest(stampedStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);
                break;

            case SUBSCRIBED:
                // RFC3921bis-04#3.1.5
                // user approves subscription to requesting contact
                handleOutboundSubscriptionApproval(stampedStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);
                break;

            case UNSUBSCRIBE:
                // RFC3921bis-04#3.3.2
                // user removes subscription from contact
                handleOutboundUnsubscription(stampedStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);
                break;

            case UNSUBSCRIBED:
                // RFC3921bis-04#3.2.2
                // user approves unsubscription of contact
                handleOutboundSubscriptionCancellation(stampedStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);
                break;

            default:
                throw new RuntimeException("unhandled case " + type.value());
            }

        } else /* inbound */{

            switch (type) {

            case SUBSCRIBE:
                // RFC3921bis-04#3.1.3
                // contact requests subscription to user
                return handleInboundSubscriptionRequest(presenceStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);

            case SUBSCRIBED:
                // RFC3921bis-04#3.1.6
                // contact approves user's subsription request
                return handleInboundSubscriptionApproval(presenceStanza, serverRuntimeContext, sessionContext,
                        registry, rosterManager);

            case UNSUBSCRIBE:
                // RFC3921bis-04#3.3.3
                // contact unsubscribes
                handleInboundUnsubscription(presenceStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);
                return null;

            case UNSUBSCRIBED:
                // RFC3921bis-04#3.2.3
                // contact denies subsription
                handleInboundSubscriptionCancellation(presenceStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);
                return null;

            default:
                throw new RuntimeException("unhandled case " + type.value());

            }
        }
        return null;
    }
View Full Code Here

                || (sessionContext != null && sessionContext
                        .getAttribute(SessionContext.SESSION_ATTRIBUTE_PRESENCE_STANZA_NO_RECEIVE) != null)) {
            return null;
        }

        PresenceStanzaType type = presenceStanza.getPresenceType();
        boolean available = PresenceStanzaType.isAvailable(type);

        if (isOutboundStanza) {
            Entity user = XMPPCoreStanzaHandler.extractUniqueSenderJID(presenceStanza, sessionContext);
            if (user == null) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.UNKNOWN_SENDER,
                        presenceStanza, StanzaErrorType.MODIFY, "sender info insufficient: no from", null, null);
            }

            if (available) {
                return handleOutboundAvailable(presenceStanza, serverRuntimeContext, sessionContext, rosterManager,
                        user, registry);
            } else if (type == UNAVAILABLE) {
                return handleOutboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext, rosterManager,
                        user, registry);
            } else if (type == PROBE) {
                return handleOutboundPresenceProbe(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == ERROR) {
                throw new RuntimeException("not implemented yet");
            } else {
                throw new RuntimeException("unhandled outbound presence case " + type.value());
            }
        } else /* inbound */{
            if (available) {
                return handleInboundAvailable(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == UNAVAILABLE) {
                return handleInboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == PROBE) {
                return handleInboundPresenceProbe(presenceStanza, serverRuntimeContext, sessionContext, registry,
                        rosterManager);
            } else if (type == ERROR) {
                throw new RuntimeException("not implemented yet");
            } else {
                throw new RuntimeException("unhandled inbound presence case " + type.value());
            }
        }
    }
View Full Code Here

                }
            } else if (deliveryException instanceof NoSuchLocalUserException) {
                // RFC3921bis#8.1: message and IQ must return service unavailable
                stanzaErrorCondition = StanzaErrorCondition.SERVICE_UNAVAILABLE;
                if (failedCoreStanza instanceof PresenceStanza) {
                    final PresenceStanzaType presenceStanzaType = ((PresenceStanza) failedCoreStanza).getPresenceType();
                    if (presenceStanzaType == null || presenceStanzaType == SUBSCRIBED
                            || presenceStanzaType == UNSUBSCRIBE || presenceStanzaType == UNSUBSCRIBED
                            || presenceStanzaType == UNAVAILABLE || presenceStanzaType == ERROR) {
                        return; // silently ignore
                    }
View Full Code Here

        // if the target is present in the room, we need to send presence updates
        // otherwise we should send messages
        Occupant targetOccupant = room.findOccupantByJID(target);
       
        // notify remaining users that user got affiliation updated
        PresenceStanzaType presenceType = null;
        Status status = null;
        Role newRole;
        Entity from;
        if(targetOccupant != null) {
            newRole = targetOccupant.getRole();
View Full Code Here

                    status);

            relayStanza(target.getJid(), presenceToKicked, serverRuntimeContext);
        }

        PresenceStanzaType availType = (newRole == Role.None) ? PresenceStanzaType.UNAVAILABLE : null;

        // notify remaining users that user got role updated
        MucUserItem presenceItem = new MucUserItem(target.getAffiliation(), newRole);
        for (Occupant occupant : room.getOccupants()) {
            Stanza presenceToRemaining = MUCStanzaBuilder.createPresenceStanza(targetInRoom, occupant.getJid(),
View Full Code Here

        // error if the from attribute is not present.
        Entity initiatingEntity = sessionContext == null ? null : sessionContext.getInitiatingEntity();
        XMPPCoreStanzaVerifier verifier = presenceStanza.getCoreVerifier();
        ResourceRegistry registry = serverRuntimeContext.getResourceRegistry();

        PresenceStanzaType type = presenceStanza.getPresenceType();

        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:
                    // RFC3921bis-04#3.1.2
                    // user requests subsription to contact
                    handleOutboundSubscriptionRequest(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                    break;

                case SUBSCRIBED:
                    // RFC3921bis-04#3.1.5
                    // user approves subscription to requesting contact
                    handleOutboundSubscriptionApproval(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                    break;

                case UNSUBSCRIBE:
                    // RFC3921bis-04#3.3.2
                    // user removes subscription from contact
                    handleOutboundUnsubscription(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                    break;

                case UNSUBSCRIBED:
                    // RFC3921bis-04#3.2.2
                    // user approves unsubscription of contact
                    handleOutboundSubscriptionCancellation(stampedStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                    break;

                default:
                    throw new RuntimeException("unhandled case " + type.value());
            }

        } else /* inbound */ {

            switch (type) {

                case SUBSCRIBE:
                    // RFC3921bis-04#3.1.3
                    // contact requests subscription to user
                    return handleInboundSubscriptionRequest(presenceStanza, serverRuntimeContext, sessionContext, registry, rosterManager);

                case SUBSCRIBED:
                    // RFC3921bis-04#3.1.6
                    // contact approves user's subsription request
                    return handleInboundSubscriptionApproval(presenceStanza, serverRuntimeContext, sessionContext, registry, rosterManager);

                case UNSUBSCRIBE:
                    // RFC3921bis-04#3.3.3
                    // contact unsubscribes
                    handleInboundUnsubscription(presenceStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                    return null;

                case UNSUBSCRIBED:
                    // RFC3921bis-04#3.2.3
                    // contact denies subsription
                    handleInboundSubscriptionCancellation(presenceStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
                    return null;

                default:
                    throw new RuntimeException("unhandled case " + type.value());

            }
        }
        return null;
    }
View Full Code Here

            (sessionContext != null &&
             sessionContext.getAttribute(SessionContext.SESSION_ATTRIBUTE_PRESENCE_STANZA_NO_RECEIVE) != null)) {
            return null;
        }

        PresenceStanzaType type = presenceStanza.getPresenceType();
        boolean available = PresenceStanzaType.isAvailable(type);

        if (isOutboundStanza) {
            Entity user = XMPPCoreStanzaHandler.extractUniqueSenderJID(presenceStanza, sessionContext);
            if (user == null) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.UNKNOWN_SENDER,
                        presenceStanza, StanzaErrorType.MODIFY,
                        "sender info insufficient: no from",
                        null, null);
            }

            if (available) {
                return handleOutboundAvailable(presenceStanza, serverRuntimeContext, sessionContext, rosterManager,
                        user, registry);
            } else if (type == UNAVAILABLE) {
                return handleOutboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext, rosterManager,
                        user, registry);
            } else if (type == PROBE) {
                return handleOutboundPresenceProbe(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == ERROR) {
                throw new RuntimeException("not implemented yet");
            } else {
                throw new RuntimeException("unhandled outbound presence case " + type.value());
            }
        } else /* inbound */ {
            if (available) {
                return handleInboundAvailable(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == UNAVAILABLE) {
                return handleInboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == PROBE) {
                return handleInboundPresenceProbe(presenceStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
            } else if (type == ERROR) {
                throw new RuntimeException("not implemented yet");
            } else {
                throw new RuntimeException("unhandled inbound presence case " + type.value());
            }
        }
    }
View Full Code Here

            (sessionContext != null &&
             sessionContext.getAttribute(SessionContext.SESSION_ATTRIBUTE_PRESENCE_STANZA_NO_RECEIVE) != null)) {
            return null;
        }

        PresenceStanzaType type = presenceStanza.getPresenceType();
        boolean available = PresenceStanzaType.isAvailable(type);

        if (isOutboundStanza) {
            Entity user = XMPPCoreStanzaHandler.extractUniqueSenderJID(presenceStanza, sessionContext);
            if (user == null) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.UNKNOWN_SENDER,
                        presenceStanza, StanzaErrorType.MODIFY,
                        "sender info insufficient: no from",
                        null, null);
            }

            if (available) {
                return handleOutboundAvailable(presenceStanza, serverRuntimeContext, sessionContext, rosterManager,
                        user, registry);
            } else if (type == UNAVAILABLE) {
                return handleOutboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext, rosterManager,
                        user, registry);
            } else if (type == PROBE) {
                return handleOutboundPresenceProbe(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == ERROR) {
                throw new RuntimeException("not implemented yet");
            } else {
                throw new RuntimeException("unhandled outbound presence case " + type.value());
            }
        } else /* inbound */ {
            if (available) {
                return handleInboundAvailable(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == UNAVAILABLE) {
                return handleInboundUnavailable(presenceStanza, serverRuntimeContext, sessionContext, registry);
            } else if (type == PROBE) {
                return handleInboundPresenceProbe(presenceStanza, serverRuntimeContext, sessionContext, registry, rosterManager);
            } else if (type == ERROR) {
                throw new RuntimeException("not implemented yet");
            } else {
                throw new RuntimeException("unhandled inbound presence case " + type.value());
            }
        }
    }
View Full Code Here

                }
            } else if (deliveryException instanceof NoSuchLocalUserException) {
                // RFC3921bis#8.1: message and IQ must return service unavailable
                stanzaErrorCondition = StanzaErrorCondition.SERVICE_UNAVAILABLE;
                if (failedCoreStanza instanceof PresenceStanza) {
                    final PresenceStanzaType presenceStanzaType = ((PresenceStanza) failedCoreStanza).getPresenceType();
                    if (presenceStanzaType == null || presenceStanzaType == SUBSCRIBED
                            || presenceStanzaType == UNSUBSCRIBE || presenceStanzaType == UNSUBSCRIBED
                            || presenceStanzaType == UNAVAILABLE || presenceStanzaType == ERROR) {
                        return; // silently ignore
                    }
View Full Code Here

TOP

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

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.