Class PresenceSubscription

    • Constructor Detail

      • PresenceSubscription

        public PresenceSubscription()
    • Method Detail

      • supTypes

        public java.util.Set<StanzaType> supTypes()
        Description copied from interface: XMPPImplIfc
        Method returns an array of all stanza types which the plugin is able to handle. If the method returns NULL, then all stanzas of all types will be passed to the plugin for processing. Otherwise only stanzas with selected types, assuming that element names and name-spaces match as well.
        Specified by:
        supTypes in interface XMPPImplIfc
        Overrides:
        supTypes in class AnnotatedXMPPProcessor
        Returns:
        a StanzaType[] array of supported stanza types.
      • process

        public void process​(Packet packet,
                            XMPPResourceConnection session,
                            NonAuthUserRepository repo,
                            java.util.Queue<Packet> results,
                            java.util.Map<java.lang.String,​java.lang.Object> settings)
                     throws XMPPException

        Performs processing of presence packets and calls different methods for particular RosterAbstract.PresenceType
        Parameters:
        packet - packet is which being processed. This parameter may never be null. Even though this is not immutable object it mustn't be altered. None of it's fields or attributes can be changed during processing.
        session - user session which keeps all the user session data and also gives an access to the user's repository data. It allows for storing information in a permanent storage or in memory only during the live of the online session. This parameter can be null if there is no online user session at the time of the packet processing.
        repo - this is a user data storage which is normally used when the user session (parameter above) is null. This is repository allows for a very restricted access only. It allows for storing some user private data (doesn't allow overwriting existing data) like messages for offline users and it also allows for reading user public data like VCard.
        results - this a collection with packets which have been generated as input packet processing results. Regardless a response to a user request is sent or the packet is forwarded to it's destination it is always required that a copy of the input packet is created and stored in the results queue.
        settings - this map keeps plugin specific settings loaded from the Tigase server configuration. In most cases it is unused, however if the plugin needs to access an external database that this is a way to pass database connection string to the plugin.
        Throws:
        XMPPException
      • processInSubscribe

        protected void processInSubscribe​(Packet packet,
                                          XMPPResourceConnection session,
                                          java.util.Queue<Packet> results,
                                          java.util.Map<java.lang.String,​java.lang.Object> settings,
                                          RosterAbstract.PresenceType pres_type)
                                   throws NotAuthorizedException,
                                          TigaseDBException,
                                          NoConnectionIdException,
                                          PolicyViolationException
        Method is responsible for processing incoming subscription request (i.e. in the receivers session manager).
        If the contact is already subscribed the an auto-reply with type='subscribded' is sent, otherwise contact is added to the roster (if it's missing/there is no current subscription), sets the subscription type to PresenceType.in_subscribe and subsequently broadcast presence update to all connected resources.
        Parameters:
        packet - packet is which being processed.
        session - user session which keeps all the user session data and also gives an access to the user's repository data.
        results - this a collection with packets which have been generated as input packet processing results.
        settings - this map keeps plugin specific settings loaded from the Tigase server configuration.
        pres_type - specifies type of the presence.
        Throws:
        NotAuthorizedException
        TigaseDBException
        NoConnectionIdException
        PolicyViolationException
      • processInSubscribed

        protected void processInSubscribed​(Packet packet,
                                           XMPPResourceConnection session,
                                           java.util.Queue<Packet> results,
                                           java.util.Map<java.lang.String,​java.lang.Object> settings,
                                           RosterAbstract.PresenceType pres_type)
                                    throws NotAuthorizedException,
                                           TigaseDBException,
                                           NoConnectionIdException,
                                           PolicyViolationException
        Method is responsible for processing incoming subscribed presence (i.e. in the receivers session manager).
        Contact is added to the roster (if it's missing/there is no current subscription), sets the subscription type to PresenceType.in_subscribed and subsequently, if subscription has changed,forwards the presence to user resource connection as well as broadcast presence update to all connected resources.
        Parameters:
        packet - packet is which being processed.
        session - user session which keeps all the user session data and also gives an access to the user's repository data.
        results - this a collection with packets which have been generated as input packet processing results.
        settings - this map keeps plugin specific settings loaded from the Tigase server configuration.
        pres_type - specifies type of the presence.
        Throws:
        NotAuthorizedException
        TigaseDBException
        NoConnectionIdException
        PolicyViolationException
      • processInUnsubscribe

        protected void processInUnsubscribe​(Packet packet,
                                            XMPPResourceConnection session,
                                            java.util.Queue<Packet> results,
                                            java.util.Map<java.lang.String,​java.lang.Object> settings,
                                            RosterAbstract.PresenceType pres_type)
                                     throws NotAuthorizedException,
                                            TigaseDBException,
                                            NoConnectionIdException,
                                            PolicyViolationException
        Method is responsible for processing incoming unsubscribe presence (i.e. in the receivers session manager).
        First method performs update of subscription of the given contact and subsequently the request is forwarded to the client to make sure it says in synch with the server (in case there was actual change in subscription). Lastly a roster push is generated to all connected resources to update them with current state of the roster and items subscriptions.
        Parameters:
        packet - packet is which being processed.
        session - user session which keeps all the user session data and also gives an access to the user's repository data.
        results - this a collection with packets which have been generated as input packet processing results.
        settings - this map keeps plugin specific settings loaded from the Tigase server configuration.
        pres_type - specifies type of the presence.
        Throws:
        NotAuthorizedException
        TigaseDBException
        NoConnectionIdException
        PolicyViolationException
      • processInUnsubscribed

        protected void processInUnsubscribed​(Packet packet,
                                             XMPPResourceConnection session,
                                             java.util.Queue<Packet> results,
                                             java.util.Map<java.lang.String,​java.lang.Object> settings,
                                             RosterAbstract.PresenceType pres_type)
                                      throws NotAuthorizedException,
                                             TigaseDBException,
                                             NoConnectionIdException,
                                             PolicyViolationException
        Method is responsible for processing incoming unsubscribed presence (i.e. in the receivers session manager).
        First method checks for the current subscription of the contact and if this verifies performs subsequent actions such as forwarding presence to the user connection to make sure it says in synch with the server, updates contact subscription with PresenceType.in_unsubscribed and in case that there was a change in user subscription send out a roster push to all connected resources to update them with current state of the roster and items subscriptions.
        Parameters:
        packet - packet is which being processed.
        session - user session which keeps all the user session data and also gives an access to the user's repository data.
        results - this a collection with packets which have been generated as input packet processing results.
        settings - this map keeps plugin specific settings loaded from the Tigase server configuration.
        pres_type - specifies type of the presence.
        Throws:
        NotAuthorizedException
        TigaseDBException
        NoConnectionIdException
        PolicyViolationException
      • processOutSubscribe

        protected void processOutSubscribe​(Packet packet,
                                           XMPPResourceConnection session,
                                           java.util.Queue<Packet> results,
                                           java.util.Map<java.lang.String,​java.lang.Object> settings,
                                           RosterAbstract.PresenceType pres_type)
                                    throws NotAuthorizedException,
                                           TigaseDBException,
                                           NoConnectionIdException,
                                           PolicyViolationException
        Method is responsible for processing outgoing subscribe and unsubscribe presence (i.e. in the sender session manager).
        Presence packet is forwarded to the destination with the JID stripped from the resource.

        In case of PresenceType.out_subscribe packet type contact is added to the roster (in case it was missing), a subscription state is being updated and, in case there was a change, a roster push is being sent to all user resources.
        In case of PresenceType.out_unsubscribe method updates contact subscription (and generates roster push if there was a change) and if the resulting contact subscription is NONE then contact is removed from the roster.

        Parameters:
        packet - packet is which being processed.
        session - user session which keeps all the user session data and also gives an access to the user's repository data.
        results - this a collection with packets which have been generated as input packet processing results.
        settings - this map keeps plugin specific settings loaded from the Tigase server configuration.
        pres_type - specifies type of the presence.
        Throws:
        NotAuthorizedException
        TigaseDBException
        NoConnectionIdException
        PolicyViolationException
      • processOutSubscribed

        protected void processOutSubscribed​(Packet packet,
                                            XMPPResourceConnection session,
                                            java.util.Queue<Packet> results,
                                            java.util.Map<java.lang.String,​java.lang.Object> settings,
                                            RosterAbstract.PresenceType pres_type)
                                     throws NotAuthorizedException,
                                            TigaseDBException,
                                            NoConnectionIdException,
                                            PolicyViolationException
        Method is responsible for processing outgoing subscribed and unsubscribed presence (i.e. in the sender session manager).
        Presence packet is forwarded to the destination with the JID stripped from the resource, a subscription state is being updated and, in case there was a change, a roster push is being sent to all user resources. Also, in case of presence type out_subscribed server send current presence to the user from each of the contact's available resources. For the presence type out_unsubscribed an unavailable presence is sent.
        Parameters:
        packet - packet is which being processed.
        session - user session which keeps all the user session data and also gives an access to the user's repository data.
        results - this a collection with packets which have been generated as input packet processing results.
        settings - this map keeps plugin specific settings loaded from the Tigase server configuration.
        pres_type - specifies type of the presence.
        Throws:
        NotAuthorizedException
        TigaseDBException
        NoConnectionIdException
        PolicyViolationException