Package org.astrogrid.samp.test
Class HubTester.ClientWatcher
- java.lang.Object
-
- org.astrogrid.samp.test.HubTester.ClientWatcher
-
- All Implemented Interfaces:
CallableClient
- Enclosing class:
- HubTester
private static class HubTester.ClientWatcher extends java.lang.Object implements CallableClient
CallableClient implementation which watches hub.event messages concerning the registration and attributes of other clients.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
clientMap_
private HubConnection
connection_
private java.lang.Throwable
error_
-
Constructor Summary
Constructors Constructor Description ClientWatcher(HubConnection connection)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HubTester.WatchedClient
getClient(java.lang.String id)
Returns a WatchedClient object corresponding to a given client public ID.HubConnection
getConnection()
Returns the hub connection used by this client.java.lang.Throwable
getError()
Returns an error if any error has been thrown during processing of hub event messages.static Metadata
getMetadata()
Returns a suitable metadata object for this client.static Subscriptions
getSubscriptions()
Returns a suitable subscriptions object for this client.private void
processMessage(java.lang.String senderId, Message msg)
void
receiveCall(java.lang.String senderId, java.lang.String msgId, Message msg)
Receives a message for which a response is required.void
receiveNotification(java.lang.String senderId, Message msg)
Receives a message for which no response is required.void
receiveResponse(java.lang.String responderId, java.lang.String msgTag, Response response)
Receives a response to a message previously sent by this client.
-
-
-
Field Detail
-
connection_
private final HubConnection connection_
-
clientMap_
private final java.util.Map clientMap_
-
error_
private java.lang.Throwable error_
-
-
Constructor Detail
-
ClientWatcher
ClientWatcher(HubConnection connection)
Constructor.- Parameters:
connection
- hub connection
-
-
Method Detail
-
getClient
public HubTester.WatchedClient getClient(java.lang.String id)
Returns a WatchedClient object corresponding to a given client public ID. This will contain information about the hub event messages this watcher has received concerning that client up till now.- Parameters:
id
- public id of a client which has been registered- Returns:
- watchedClient object if any messages have been received
about
id
, otherwise null
-
getError
public java.lang.Throwable getError()
Returns an error if any error has been thrown during processing of hub event messages.- Returns:
- deferred throwable, or null in case of no problems
-
getConnection
public HubConnection getConnection()
Returns the hub connection used by this client.- Returns:
- hub connection
-
receiveCall
public void receiveCall(java.lang.String senderId, java.lang.String msgId, Message msg)
Description copied from interface:CallableClient
Receives a message for which a response is required. The implementation must take care to call the hub'sreply
method at some future point.- Specified by:
receiveCall
in interfaceCallableClient
- Parameters:
senderId
- public ID of sending clientmsgId
- message identifier for later use with replymsg
- message
-
receiveNotification
public void receiveNotification(java.lang.String senderId, Message msg)
Description copied from interface:CallableClient
Receives a message for which no response is required.- Specified by:
receiveNotification
in interfaceCallableClient
- Parameters:
senderId
- public ID of sending clientmsg
- message
-
processMessage
private void processMessage(java.lang.String senderId, Message msg) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveResponse
public void receiveResponse(java.lang.String responderId, java.lang.String msgTag, Response response)
Description copied from interface:CallableClient
Receives a response to a message previously sent by this client.- Specified by:
receiveResponse
in interfaceCallableClient
- Parameters:
responderId
- public ID of responding clientmsgTag
- client-defined tag labelling previously-sent messageresponse
- returned response object
-
getSubscriptions
public static Subscriptions getSubscriptions()
Returns a suitable subscriptions object for this client.- Returns:
- subscriptions
-
getMetadata
public static Metadata getMetadata()
Returns a suitable metadata object for this client.
-
-