Package org.astrogrid.samp.hub
Class HubCallableClient
- java.lang.Object
-
- org.astrogrid.samp.hub.HubCallableClient
-
- All Implemented Interfaces:
CallableClient
class HubCallableClient extends java.lang.Object implements CallableClient
CallableClient implementation used by the hub client. This isn't exactly essential, but it enables the hub client (the client which represents the hub itself) to subscribe to some MTypes. Possibly useful for testing purposes etc.- Since:
- 28 Jan 2011
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description private HubConnection
connection_
private AbstractMessageHandler[]
handlers_
-
Constructor Summary
Constructors Constructor Description HubCallableClient(HubConnection connection, AbstractMessageHandler[] handlers)
Constructs a HubCallableClient with a given set of handlers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private AbstractMessageHandler
getHandler(java.lang.String mtype)
Returns a handler owned by this callable client which can handle a given MType.Subscriptions
getSubscriptions()
Returns the subscriptions corresponding to the messages that this receiver can deal with.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_
-
handlers_
private final AbstractMessageHandler[] handlers_
-
-
Constructor Detail
-
HubCallableClient
public HubCallableClient(HubConnection connection, AbstractMessageHandler[] handlers)
Constructs a HubCallableClient with a given set of handlers.- Parameters:
connection
- connection to hub servicehandlers
- array of message handlers
-
-
Method Detail
-
receiveCall
public void receiveCall(java.lang.String senderId, java.lang.String msgId, Message msg) throws SampException
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- Throws:
SampException
-
receiveNotification
public void receiveNotification(java.lang.String senderId, Message msg) throws SampException
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- Throws:
SampException
-
receiveResponse
public void receiveResponse(java.lang.String responderId, java.lang.String msgTag, Response response) throws SampException
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- Throws:
SampException
-
getSubscriptions
public Subscriptions getSubscriptions()
Returns the subscriptions corresponding to the messages that this receiver can deal with.- Returns:
- subscriptions list
-
getHandler
private AbstractMessageHandler getHandler(java.lang.String mtype) throws SampException
Returns a handler owned by this callable client which can handle a given MType. If more than one applies, the first one encountered is returned.- Parameters:
mtype
- MType to handle- Returns:
- handler for
mtype
- Throws:
SampException
- if no suitable handler exists
-
-