Package org.astrogrid.samp.gui
Class AbstractCallActionManager.CallResponseHandler
- java.lang.Object
-
- org.astrogrid.samp.gui.AbstractCallActionManager.CallResponseHandler
-
- All Implemented Interfaces:
java.util.EventListener
,javax.swing.event.ChangeListener
,ResponseHandler
- Enclosing class:
- AbstractCallActionManager
private class AbstractCallActionManager.CallResponseHandler extends java.lang.Object implements ResponseHandler, javax.swing.event.ChangeListener
ResponseHandler implementation for use by this class. It handles all SAMP responses for calls which have been made by this object and passes them on to the appropriate ResultHandlers.
-
-
Constructor Summary
Constructors Constructor Description CallResponseHandler()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.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.private void
hubDisconnected()
Called when the connection to the hub disappears.boolean
ownsTag(java.lang.String tag)
Indicates whether this handler will process the response with a given message tag.private void
processResponse(java.lang.String tag, AbstractCallActionManager.TagInfo info, java.lang.String responderId, Response response)
Does the work of passing on a received response to a registered result handler.void
receiveResponse(HubConnection connection, java.lang.String responderId, java.lang.String tag, Response response)
Processes a response to an earlier message.void
registerHandler(java.lang.String tag, Client[] recipients, ResultHandler handler)
Registers a result handler to handle results corresponding to a message tag.void
stateChanged(javax.swing.event.ChangeEvent evt)
-
-
-
Method Detail
-
createTag
public java.lang.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 toregisterHandler(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(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 ofcreateTag()
recipients
- clients from which responses are expectedhandler
- result handler for responses; may be null if no handling is required
-
ownsTag
public boolean ownsTag(java.lang.String tag)
Description copied from interface:ResponseHandler
Indicates whether this handler will process the response with a given message tag.- Specified by:
ownsTag
in interfaceResponseHandler
- Parameters:
tag
- tag with which earlier call was labelled- Returns:
- true iff this handler wants to process the response labelled
with
msgTag
-
receiveResponse
public void receiveResponse(HubConnection connection, java.lang.String responderId, java.lang.String tag, Response response)
Description copied from interface:ResponseHandler
Processes a response to an earlier message. Will only be called formsgTag
values which returntrue
fromResponseHandler.ownsTag(java.lang.String)
.- Specified by:
receiveResponse
in interfaceResponseHandler
- Parameters:
connection
- hub connectionresponderId
- client id of client sending responsetag
- message tag from previous callresponse
- response object
-
processResponse
private void processResponse(java.lang.String tag, AbstractCallActionManager.TagInfo info, java.lang.String responderId, Response response)
Does the work of passing on a received response to a registered result handler.- Parameters:
tag
- message taginfo
- tag handling information objectresponderId
- client ID of responderresponse
- response object
-
stateChanged
public void stateChanged(javax.swing.event.ChangeEvent evt)
- Specified by:
stateChanged
in interfacejavax.swing.event.ChangeListener
-
hubDisconnected
private void hubDisconnected()
Called when the connection to the hub disappears.
-
-