# Class SampSender

java.lang.Object
uk.ac.starlink.topcat.activate.SampSender

public class SampSender extends Object
Takes care of sending SAMP messages from activation methods.

It does a similar job to its predecessor `SendManager`, which it cannibalises, but unlike that class it provides support for synchronous message sending (call/callAll), with result strings handed back to the calling code rather than just discarded or pushed through the logging system.

Since:
  27 Mar 2018
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`SampSender(String mtype)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Outcome`
`activateMessage(Map<?,?> message)`
Invoked to perform an activation action which involves sending a SAMP message to this sender's currently selected target client(s).
`ListModel<org.astrogrid.samp.Client>`
`getClientListModel()`
Returns a list of the clients that are current possible targets for this sender's messages (subscribed to the relevant MType).
`ComboBoxModel<Object>`
`getClientSelectionModel()`
Returns a ComboBoxModel listing clients that are subscribed to this sender's MType.
`org.astrogrid.samp.gui.GuiHubConnector`
`getConnector()`
Returns this sender's hub connector.
`String`
`getMType()`
Returns the MType of the message that this sender will send.
`TopcatSampControl`
`getSampControl()`
Returns this sender's Samp control.
`String`
`getUnavailableText()`
Returns a message explaining why this sender can't do any useful work at the moment.
`boolean`
`hasClients()`
Indicates whether any registered clients are subscribed to this sender's MType.
`boolean`
`isAvailable()`
Indicates whether this sender has a chance of working.

### Methods inherited from class Object

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

## Constructor Details

### SampSender

public SampSender(String mtype)
Constructor. The supplied MType determines what the offered list of recipient clients will contain.

Parameters:
  `mtype` - message type to which this sender is sensitive

## Method Details

### getMType

public String getMType()
Returns the MType of the message that this sender will send.

Returns:
  MType

### isAvailable

public boolean isAvailable()
Indicates whether this sender has a chance of working.

Returns:
  false if this will never work

### getClientListModel

public ListModel<org.astrogrid.samp.Client> getClientListModel()
Returns a list of the clients that are current possible targets for this sender's messages (subscribed to the relevant MType). If this list is empty, then the sender can't currently do any useful work.

Returns:
  listmodel containing appropriately-subscribed clients

### hasClients

public boolean hasClients()
Indicates whether any registered clients are subscribed to this sender's MType.

Returns:
  true iff at least one subscribed client is present

### getClientSelectionModel

public ComboBoxModel<Object> getClientSelectionModel()
Returns a ComboBoxModel listing clients that are subscribed to this sender's MType. It may also contain an object representing broadcast.

Returns:
  client selection list

### getSampControl

public TopcatSampControl getSampControl()
Returns this sender's Samp control.

Returns:
  samp control object

### getConnector

public org.astrogrid.samp.gui.GuiHubConnector getConnector()
Returns this sender's hub connector.

Returns:
  connector object

### activateMessage

public Outcome activateMessage(Map<?,?> message)
Invoked to perform an activation action which involves sending a SAMP message to this sender's currently selected target client(s).

Parameters:
  `message` - message to send
Returns:
  outcome

### getUnavailableText

public String getUnavailableText()
Returns a message explaining why this sender can't do any useful work at the moment. If it can, null is returned.

Returns:
  unavailablity message, or null if all is working