Package org.astrogrid.samp.gui

# Class Transmission

java.lang.Object
org.astrogrid.samp.gui.Transmission

public class Transmission extends Object
Describes the properties of a message which has been sent from one client to another. Methods which might change the state of instances of this class should be invoked only from the AWT event dispatch thread.

Since:
  20 Nov 2008
Author:
  Mark Taylor

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`Transmission.Status`
Describes the status of a transmission in terms that can be presented in the GUI.

## Constructor Summary

Constructors
Constructor
Description
`Transmission(Client sender, Client receiver, Message msg, String msgTag, String msgId)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addChangeListener(ChangeListener listener)`
Adds a listener which will be notified if the state of this transmission changes (if a response or failure is signalled).
`long`
`getDoneTime()`
Returns the epoch at which this transmission was completed.
`Throwable`
`getError()`
Returns a Throwable which prevented normal resolution of this transmission.
`Message`
`getMessage()`
Returns the message which was sent.
`String`
`getMessageId()`
Returns the message ID associated with this message.
`String`
`getMessageTag()`
Returns the message tag corresponding to this transmission.
`Client`
`getReceiver()`
Returns the client to which this transmission was sent.
`Response`
`getResponse()`
Returns the response for this transmission.
`Client`
`getSender()`
Returns the client which sent this transmission.
`Transmission.Status`
`getStatus()`
Returns an object which describes the current status of this transmission in terms which can be presented to the GUI.
`boolean`
`isDone()`
Indicates whether further changes to the state of this object are expected, that is if a response/failure is yet to be received.
`void`
`removeChangeListener(ChangeListener listener)`
Removes a listener previously added by `addChangeListener(javax.swing.event.ChangeListener)`.
`void`
`setError(Throwable error)`
Associates an error with this transmission.
`void`
`setReceiverUnregistered()`
Indicates that the receiver of this transmission has unregistered.
`void`
`setResponse(Response response)`
Sets the response for this transmission.
`void`
`setSenderUnregistered()`
Indicates that the sender of this transmission has unregistered.

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

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

## Constructor Details

### Transmission

public Transmission(Client sender, Client receiver, Message msg, String msgTag, String msgId)
Constructor.

Parameters:
  `sender` - sender
  `receiver` - receiver
  `msg` - message
  `msgTag` - message tag
  `msgId` - message ID

## Method Details

### getSender

public Client getSender()
Returns the client which sent this transmission.

Returns:
  sender

### getReceiver

public Client getReceiver()
Returns the client to which this transmission was sent.

Returns:
  receiver

### getMessage

public Message getMessage()
Returns the message which was sent.

Returns:
  message

### getMessageTag

public String getMessageTag()
Returns the message tag corresponding to this transmission. Will be null for notify-type sends.

Returns:
  msg tag

### getMessageId

public String getMessageId()
Returns the message ID associated with this message. This is the identifier passed to the receiver which it uses to match messages with responses; it will be null iff the transmission used the notify delivery pattern (no response expected).

Returns:
  msgId; possibly null

### setResponse

public void setResponse(Response response)
Sets the response for this transmission.

Parameters:
  `response` - response

### getResponse

public Response getResponse()
Returns the response for this transmission. Will be null if no response has (yet) arrived.

Returns:
  response

### setError

public void setError(Throwable error)
Associates an error with this transmission. This is probably an indication that the send failed or some other non-SAMP event intervened to prevent normal resolution.

Parameters:
  `error` - throwable causing the failure

### getError

public Throwable getError()
Returns a Throwable which prevented normal resolution of this transmission.

Returns:
  error

### setSenderUnregistered

public void setSenderUnregistered()
Indicates that the sender of this transmission has unregistered.

### setReceiverUnregistered

public void setReceiverUnregistered()
Indicates that the receiver of this transmission has unregistered.

### getDoneTime

public long getDoneTime()
Returns the epoch at which this transmission was completed. If it is still pending (`isDone()`==false), the returned value will be (way) in the future.

Returns:
  value of `System.currentTimeMillis()` at which `isDone()` first returned true

### isDone

public boolean isDone()
Indicates whether further changes to the state of this object are expected, that is if a response/failure is yet to be received.

Returns:
  true iff no further changes are expected

### getStatus

public Transmission.Status getStatus()
Returns an object which describes the current status of this transmission in terms which can be presented to the GUI.

### addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener which will be notified if the state of this transmission changes (if a response or failure is signalled). The `ChangeEvent`s sent to these listeners will have a source which is this Transmission.

Parameters:
  `listener` - listener to add

### removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes a listener previously added by `addChangeListener(javax.swing.event.ChangeListener)`.

Parameters:
  `listener` - listener to remove