Package uk.ac.starlink.ttools.mode
Class ClientRegWatcher
- java.lang.Object
-
- uk.ac.starlink.ttools.mode.ClientRegWatcher
-
- All Implemented Interfaces:
org.astrogrid.samp.client.CallableClient
public class ClientRegWatcher extends java.lang.Object implements org.astrogrid.samp.client.CallableClient
Callable client implementation which can watch for registration of a given named application.- Since:
- 9 Jan 2009
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description ClientRegWatcher(org.astrogrid.samp.client.HubConnection connection)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getIdFromName(java.lang.String name)
Returns the client ID of a client with a given name if one is registered.org.astrogrid.samp.Subscriptions
getSubscriptions()
Returns the subscriptions object indicating the MTypes this client can handle.void
receiveCall(java.lang.String senderId, java.lang.String msgId, org.astrogrid.samp.Message msg)
void
receiveNotification(java.lang.String senderId, org.astrogrid.samp.Message msg)
void
receiveResponse(java.lang.String responderId, java.lang.String msgTag, org.astrogrid.samp.Response response)
java.lang.String
waitForIdFromName(java.lang.String name, long waitMillis)
Blocks until a client with a given name is regstered, and then returns its client ID.org.astrogrid.samp.Response
waitForResponse(java.lang.String msgTag)
Blocks until a response with a given tag is received, then returns that response.
-
-
-
Method Detail
-
getSubscriptions
public org.astrogrid.samp.Subscriptions getSubscriptions()
Returns the subscriptions object indicating the MTypes this client can handle.- Returns:
- subscriptions
-
waitForIdFromName
public java.lang.String waitForIdFromName(java.lang.String name, long waitMillis)
Blocks until a client with a given name is regstered, and then returns its client ID. If a given timeout value is exceeded, null is returned- Parameters:
name
- client name soughtwaitMillis
- maximum number of milliseconds to wait- Returns:
- client ID for client with name
name
, or null if timeout is exceeded
-
getIdFromName
public java.lang.String getIdFromName(java.lang.String name)
Returns the client ID of a client with a given name if one is registered.- Parameters:
name
- client name- Returns:
- ID of client with name
name
, or null if none is currently registered
-
waitForResponse
public org.astrogrid.samp.Response waitForResponse(java.lang.String msgTag)
Blocks until a response with a given tag is received, then returns that response.- Parameters:
msgTag
- message tag- Returns:
- response
-
receiveCall
public void receiveCall(java.lang.String senderId, java.lang.String msgId, org.astrogrid.samp.Message msg) throws org.astrogrid.samp.client.SampException
- Specified by:
receiveCall
in interfaceorg.astrogrid.samp.client.CallableClient
- Throws:
org.astrogrid.samp.client.SampException
-
receiveNotification
public void receiveNotification(java.lang.String senderId, org.astrogrid.samp.Message msg)
- Specified by:
receiveNotification
in interfaceorg.astrogrid.samp.client.CallableClient
-
receiveResponse
public void receiveResponse(java.lang.String responderId, java.lang.String msgTag, org.astrogrid.samp.Response response)
- Specified by:
receiveResponse
in interfaceorg.astrogrid.samp.client.CallableClient
-
-