Class MessageFilter

    • Method Summary

      Modifier and Type Method Description
      TextMessage intercept​(TextMessage message)
      Intercept a message and return the same message, a modified version of the incoming message, or null, if the message should be filtered out and dropped by the AbstractMessageEndpoint
      static MessageFilter messageFilter​(java.util.function.Predicate<TextMessage> predicate)
      Creates a MessageFilter that is used to filter messages from message endpoints.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • messageFilter

        public static MessageFilter messageFilter​(java.util.function.Predicate<TextMessage> predicate)
        Creates a MessageFilter that is used to filter messages from message endpoints.

        Messages will be dropped, if predicate.test(message) is false

        Parameters:
        predicate - the predicate used to select messages
        Returns:
        MessageFilter
      • intercept

        @Nullable
        public final TextMessage intercept​(@Nonnull
                                           TextMessage message)
        Intercept a message and return the same message, a modified version of the incoming message, or null, if the message should be filtered out and dropped by the AbstractMessageEndpoint The intercept method of a MessageFilter returns the intercepted message, if the filter predicate returns true. Otherwise, null is returned and the message will be dropped.
        Specified by:
        intercept in interface MessageInterceptor
        Parameters:
        message - the channel-layer message with payload-type beeing a String
        Returns:
        intercepted version of the message, or null if the message should be dropped.