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`

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

## Field Summary

### Fields inherited from class org.astrogrid.samp.gui.SendActionManager

`BROADCAST_TARGET`

## Constructor Summary

Constructors
Constructor
Description
`AbstractCallActionManager(Component parent, GuiHubConnector connector, ListModel clientListModel)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected abstract Action`
`createBroadcastAction()`
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.
`String`
`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.
`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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AbstractCallActionManager

public AbstractCallActionManager(Component parent, GuiHubConnector connector, 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 `Client`s

## Method Details

### createBroadcastAction

protected abstract 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 Map createMessage(Client client) throws 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:
  `Exception`

### getSendAction

protected 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

### createTag

public String 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 to `registerHandler(java.lang.String, org.astrogrid.samp.Client[], org.astrogrid.samp.client.ResultHandler)` should be made for the returned tag.

Returns:
  new tag

### registerHandler

public void registerHandler(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