Class FMUCHandler


  • public class FMUCHandler
    extends Object
    • Field Detail

      • FMUC

        public static final org.dom4j.QName FMUC
        Qualified name of the element that denotes FMUC functionality, as specified by XEP-0289.
    • Constructor Detail

      • FMUCHandler

        public FMUCHandler​(@Nonnull
                           MUCRoom chatroom)
    • Method Detail

      • startOutbound

        public void startOutbound()
        Starts federation, which will cause a federation attempt with the outbound ('joined') node, if one is configured, and there currently are occupants in the room.
      • stop

        public void stop()
        Stops federation, which will cause any joined and joining nodes to be disconnected.
      • stopInbound

        public void stopInbound()
        Stops inbound federation, which will cause existing federation with all of the inbound ('joining') nodes, if any are established, to be teared down.
      • stopInbound

        public void stopInbound​(@Nonnull
                                org.xmpp.packet.JID peer)
        Stops inbound federation, which will cause existing federation with one specific inbound ('joining') nodes to be teared down.
        Parameters:
        peer - the address of the remote node (must be a bare JID).
      • stopOutbound

        public void stopOutbound()
        Stops outbound federation, which will cause existing federation with the outbound ('joined') node, if one is established, to be teared down.
      • applyConfigurationChanges

        public void applyConfigurationChanges()
        Reads configuration from the room instance that is being services by this handler, and applies relevant changes.
      • propagate

        public CompletableFuture<?> propagate​(@Nonnull
                                              org.xmpp.packet.Packet stanza,
                                              @Nonnull
                                              MUCRole sender)
        Propagates a stanza to the FMUC set, if FMUC is active for this room. Note that when a master-slave mode is active, we need to wait for an echo back, before the message can be broadcasted locally. This method will return a CompletableFuture object that is completed as soon as processing can continue. This doesn't necessarily mean that processing/propagating has been completed (eg: when the FMUC is configured to use master-master mode, a completed Future instance will be returned. When FMUC is not active, this method will return a completed Future instance.
        Parameters:
        stanza - the stanza to be propagated through FMUC.
        sender - the role of the sender that is the original author of the stanza.
        Returns:
        A future object that completes when the stanza can be propagated locally.
      • join

        public Future<?> join​(@Nonnull
                              MUCRole mucRole)
        Makes a user in our XMPP domain join the FMUC room. The join event is propagated to all nodes in the FMUC set that the room is part of. When 'outbound' federation is desired, but has not yet been established (when this is the first user to join the room), federation is initiated. Depending on the configuration and state of the FMUC set, the join operation is considered 'blocking'. In case of a FMUC based on master-slave mode, for example, the operation cannot continue until the remote FMUC node has echo'd back the join. To accommodate this behavior, this method will return a Future instance. The Future will immediately be marked as 'done' when the operation need not have 'blocking' behavior. Note that in such cases, the Future being 'done' does explicitly not indicate that the remote FMUC node has received, processed and/or accepted the event. If the local room is not configured to federate with another room, an invocation of this method will do nothing.
        Parameters:
        mucRole - The role in which the user is joining the room.
        Returns:
        A future object that completes when the stanza can be propagated locally.
      • join

        protected Future<?> join​(@Nonnull
                                 MUCRole mucRole,
                                 boolean includeInbound,
                                 boolean includeOutbound)
      • createCopyWithoutFMUC

        public static <S extends org.xmpp.packet.Packet> S createCopyWithoutFMUC​(S stanza)
        Removes FMUC child elements from the stanza, if such an element exists. This method provides the functionally opposite implementation of enrichWithFMUCElement(Packet, MUCRole).
        Type Parameters:
        S - Type of stanza
        Parameters:
        stanza - The stanza from which an FMUC child element is to be removed.
        Returns:
        A copy of the stanza, without FMUC child element.
      • process

        public void process​(@Nonnull
                            org.xmpp.packet.Packet stanza)
      • getFMUCFromJID

        public static org.xmpp.packet.JID getFMUCFromJID​(@Nonnull
                                                         org.xmpp.packet.Packet stanza)
        Parses the JID from an FMUC stanza. More specifically, this method returns the JID representation of the 'from' attribute value of the 'fmuc' child element in the stanza. A runtime exception is thrown when no such value exists, or when that value is not a valid JID.
        Parameters:
        stanza - An FMUC stanza
        Returns:
        A JID.
        Throws:
        RuntimeException - when no valid JID value is found in the 'from' attribute of the FMUC child element.
      • isSubject

        public static boolean isSubject​(@Nonnull
                                        org.xmpp.packet.Packet stanza)
      • isFMUCReject

        public static boolean isFMUCReject​(@Nonnull
                                           org.xmpp.packet.Packet stanza)
      • isFMUCJoinRequest

        public static boolean isFMUCJoinRequest​(@Nonnull
                                                org.xmpp.packet.Packet stanza)
      • abortOutboundJoinProgress

        public void abortOutboundJoinProgress()