Class AbstractMessageHandler

    • Field Detail

      • logger_

        private final java.util.logging.Logger logger_
    • Constructor Detail

      • AbstractMessageHandler

        protected AbstractMessageHandler​(java.util.Map subscriptions)
        Constructor using a given subscriptions map.
        Parameters:
        subscriptions - Subscriptions-like map defining which MTypes this handler can process
      • AbstractMessageHandler

        protected AbstractMessageHandler​(java.lang.String[] mtypes)
        Constructor using a given list of subscribed MTypes.
        Parameters:
        mtypes - list of MTypes which this handler can process
      • AbstractMessageHandler

        protected AbstractMessageHandler​(java.lang.String mtype)
        Constructor using a single subscribed MType.
        Parameters:
        mtype - single MType which this handler can process
    • Method Detail

      • processCall

        public abstract java.util.Map processCall​(HubConnection connection,
                                                  java.lang.String senderId,
                                                  Message message)
                                           throws java.lang.Exception
        Implements message processing. Implementations should normally return a map which contains the samp.result part of the call response, that is the MType-specific return value name->value map. As a special case, returning null is equivalent to returning an empty map. However, if createResponse(java.util.Map) is overridden, the return value semantics may be different.
        Parameters:
        connection - hub connection
        senderId - public ID of sender client
        message - message with MType this handler is subscribed to
        Returns:
        result of handling this message; exact semantics determined by createResponse implementation
        Throws:
        java.lang.Exception
      • createResponse

        protected Response createResponse​(java.util.Map processOutput)
        Invoked by receiveCall to create a success response from the result of calling processCall.

        The default implementation calls Response.createSuccessResponse(java.util.Map)(processOutput), first transforming a null value to an empty map for convenience. However, it may be overridden for more flexibility (for instance in order to return non-OK responses).

        Parameters:
        processOutput - a Map returned by processCall
      • setSubscriptions

        public void setSubscriptions​(java.util.Map subscriptions)
        Sets the subscriptions map. Usually this is called by the constructor, but it may be reset manually.
        Parameters:
        subscriptions - Subscriptions-like map defining which MTypes this handler can process
      • getSubscriptions

        public java.util.Map getSubscriptions()
        Description copied from interface: MessageHandler
        Returns a Subscriptions map corresponding to the messages handled by this object. Only messages with MTypes which match the keys of this map will be passed to this object.
        Specified by:
        getSubscriptions in interface MessageHandler
        Returns:
        Subscriptions-like map