Class TopicManager

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class TopicManager
    extends Object
    implements Closeable
    TopicManager is responsible for topic registration multiplexing.

    As AM does not manage multiple subscriptions to the same topic from a client, this class has to do the subscription multiplexing itself. In other words, it maintains a map of subscribed TopicManager.Topics, each of which has a reference counter used to detect when an un-registration action needs to be performed.

    The first time a topic is subscribed to, this class sends a subscription message to AM and waits for the acknowledgment. Every subsequent subscription to the same topic will reuse the same "connection" without sending a subscription request. Inversely, no un-subscription request is sent to AM until the last reference is removed.

    • Constructor Detail

      • TopicManager

        public TopicManager​(Supplier<String> id)
        TopicManager constructor taking an ID generator and message handler to handle notifications.
        Parameters:
        id - an ID generator, never null
    • Method Detail

      • renewSession

        public void renewSession​(WebSocketAdapter webSocket)
        Refresh the TopicManager session with a new WebSocket (on reconnection).
        Parameters:
        webSocket - the WebSocket to use to handle notification registration