Class AbstractCallActionManager

  • Direct Known Subclasses:
    IndividualCallActionManager, UniformCallActionManager

    public abstract class AbstractCallActionManager
    extends SendActionManager
    Partial SendActionManager implementation which uses the Asynchronous Call/Response delivery pattern. It supplies most of the machinery required for tracking what happened to responses to messages sent at the same time, but does not implement the actual createBroadcastAction() method. Subclasses are provided which do this.
    Since:
    11 Nov 2008
    Author:
    Mark Taylor
    • Constructor Detail

      • AbstractCallActionManager

        public AbstractCallActionManager​(java.awt.Component parent,
                                         GuiHubConnector connector,
                                         javax.swing.ListModel clientListModel)
        Constructor.
        Parameters:
        parent - parent component
        connector - hub connector
        clientListModel - list model containing only those clients which are suitable recipients; all elements must be Clients
    • Method Detail

      • createBroadcastAction

        protected abstract javax.swing.Action createBroadcastAction()
        Must be implemented by concrete subclasses.
        Specified by:
        createBroadcastAction in class SendActionManager
        Returns:
        broadcast action; may be null if broadcast is not required
      • createResultHandler

        protected ResultHandler createResultHandler​(HubConnection connection,
                                                    Message msg,
                                                    Client[] recipients)
        Returns an object which will be informed of the results of a single- or multiple-recipient send as they arrive. This method will be called from the event dispatch thread.

        The default implementation returns an instance of LogResultHandler.

        Parameters:
        connection - connection object
        msg - the message which was sent
        recipients - the recipients to whom the message was sent
        Returns:
        result handler object
      • dispose

        public void dispose()
        Releases resources associated with this object. Specifically, it removes listeners from the hub connector. Following a call to this method, this object should not be used again.
        Overrides:
        dispose in class SendActionManager
      • createMessage

        protected abstract java.util.Map createMessage​(Client client)
                                                throws java.lang.Exception
        Returns the Message object which is to be transmitted by this manager to a given client. This is called by the action returned by getSendAction(org.astrogrid.samp.Client).
        Parameters:
        client - target
        Returns:
        message
        Throws:
        java.lang.Exception
      • getSendAction

        protected javax.swing.Action getSendAction​(Client client)
        Description copied from class: SendActionManager
        Returns an action which can perform a single-client send associated with this object. If it implements equals (and hashCode) intelligently there will be efficiency advantages. The enabled status of such actions will be managed by this object.
        Specified by:
        getSendAction in class SendActionManager
        Parameters:
        client - recipient client
        Returns:
        action which sends to the given client
      • registerHandler

        public void registerHandler​(java.lang.String tag,
                                    Client[] recipients,
                                    ResultHandler handler)
        Registers a result handler to handle results corresponding to a message tag.
        Parameters:
        tag - tag returned by an earlier invocation of createTag()
        recipients - clients from which responses are expected
        handler - result handler for responses; may be null if no handling is required