Package org.astrogrid.samp.gui
Class AbstractCallActionManager
java.lang.Object
org.astrogrid.samp.gui.SendActionManager
org.astrogrid.samp.gui.AbstractCallActionManager
- Direct Known Subclasses:
IndividualCallActionManager
,UniformCallActionManager
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
-
Field Summary
Fields inherited from class org.astrogrid.samp.gui.SendActionManager
BROADCAST_TARGET
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractCallActionManager
(Component parent, GuiHubConnector connector, ListModel clientListModel) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Action
Must be implemented by concrete subclasses.protected abstract Map
createMessage
(Client client) Returns the Message object which is to be transmitted by this manager to a given client.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.Creates and returns a new tag which will be attached to an outgoing message, and updates internal structures so that it will be recognised in the future.void
dispose()
Releases resources associated with this object.protected Action
getSendAction
(Client client) Returns an action which can perform a single-client send associated with this object.void
registerHandler
(String tag, Client[] recipients, ResultHandler handler) Registers a result handler to handle results corresponding to a message tag.Methods inherited from class org.astrogrid.samp.gui.SendActionManager
createSendMenu, createTargetAction, createTargetSelector, disposeSendMenu, getBroadcastAction, getBroadcastIcon, getClientListModel, getConnector, getSendIcon, setEnabled, updateState
-
Constructor Details
-
AbstractCallActionManager
public AbstractCallActionManager(Component parent, GuiHubConnector connector, ListModel clientListModel) Constructor.- Parameters:
parent
- parent componentconnector
- hub connectorclientListModel
- list model containing only those clients which are suitable recipients; all elements must beClient
s
-
-
Method Details
-
createBroadcastAction
Must be implemented by concrete subclasses.- Specified by:
createBroadcastAction
in classSendActionManager
- 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 objectmsg
- the message which was sentrecipients
- 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 classSendActionManager
-
createMessage
Returns the Message object which is to be transmitted by this manager to a given client. This is called by the action returned bygetSendAction(org.astrogrid.samp.Client)
.- Parameters:
client
- target- Returns:
- message
- Throws:
Exception
-
getSendAction
Description copied from class:SendActionManager
Returns an action which can perform a single-client send associated with this object. If it implementsequals
(andhashCode
) intelligently there will be efficiency advantages. The enabled status of such actions will be managed by this object.- Specified by:
getSendAction
in classSendActionManager
- Parameters:
client
- recipient client- Returns:
- action which sends to the given client
-
createTag
Creates and returns a new tag which will be attached to an outgoing message, and updates internal structures so that it will be recognised in the future. A subsequent call toregisterHandler(java.lang.String, org.astrogrid.samp.Client[], org.astrogrid.samp.client.ResultHandler)
should be made for the returned tag.- Returns:
- new tag
-
registerHandler
Registers a result handler to handle results corresponding to a message tag.- Parameters:
tag
- tag returned by an earlier invocation ofcreateTag()
recipients
- clients from which responses are expectedhandler
- result handler for responses; may be null if no handling is required
-