Package org.astrogrid.samp.gui
Class MessageTrackerHubConnector.MessageTrackerHubConnection
- java.lang.Object
-
- org.astrogrid.samp.gui.WrapperHubConnection
-
- org.astrogrid.samp.gui.MessageTrackerHubConnector.MessageTrackerHubConnection
-
- All Implemented Interfaces:
HubConnection
- Enclosing class:
- MessageTrackerHubConnector
private class MessageTrackerHubConnector.MessageTrackerHubConnection extends WrapperHubConnection
HubConnection object which intercepts calls to keep track of outgoing and incoming messages.
-
-
Field Summary
Fields Modifier and Type Field Description private Client
selfClient_
-
Constructor Summary
Constructors Constructor Description MessageTrackerHubConnection(HubConnection base)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
call(java.lang.String recipientId, java.lang.String msgTag, java.util.Map msg)
Sends a message to a given client expecting a response.java.util.Map
callAll(java.lang.String msgTag, java.util.Map msg)
Sends a message to all subscribed clients expecting responses.Response
callAndWait(java.lang.String recipientId, java.util.Map msg, int timeout)
Sends a message synchronously to a client, waiting for the response.(package private) Client
getSelfClient()
Returns a Client object for use in Transmission objects which represents this connection's owner.void
notify(java.lang.String recipientId, java.util.Map msg)
Sends a message to a given client without wanting a response.java.util.List
notifyAll(java.util.Map msg)
Sends a message to all subscribed clients without wanting a response.void
reply(java.lang.String msgId, java.util.Map response)
Supplies a response to a previously received message.void
setCallable(CallableClient callable)
Tells the hub how it can perform callbacks on the client by providing a CallableClient object.-
Methods inherited from class org.astrogrid.samp.gui.WrapperHubConnection
declareMetadata, declareSubscriptions, getMetadata, getRegInfo, getRegisteredClients, getSubscribedClients, getSubscriptions, ping, unregister
-
-
-
-
Field Detail
-
selfClient_
private Client selfClient_
-
-
Constructor Detail
-
MessageTrackerHubConnection
MessageTrackerHubConnection(HubConnection base)
Constructor.- Parameters:
base
- connection on which this one is based
-
-
Method Detail
-
getSelfClient
Client getSelfClient()
Returns a Client object for use in Transmission objects which represents this connection's owner. This has to be the same object as is used in the client set, otherwise the various models don't get updated correctly. For this reason, it has to be obtained lazily, after the client set has been initialised.- Returns:
- self client object
-
notify
public void notify(java.lang.String recipientId, java.util.Map msg) throws SampException
Description copied from interface:HubConnection
Sends a message to a given client without wanting a response.- Specified by:
notify
in interfaceHubConnection
- Overrides:
notify
in classWrapperHubConnection
- Parameters:
recipientId
- public-id of client to receive messagemsg
-Message
-like map- Throws:
SampException
-
notifyAll
public java.util.List notifyAll(java.util.Map msg) throws SampException
Description copied from interface:HubConnection
Sends a message to all subscribed clients without wanting a response.- Specified by:
notifyAll
in interfaceHubConnection
- Overrides:
notifyAll
in classWrapperHubConnection
- Parameters:
msg
-Message
-like map- Returns:
- list of public-ids for clients to which the notify will be sent
- Throws:
SampException
-
call
public java.lang.String call(java.lang.String recipientId, java.lang.String msgTag, java.util.Map msg) throws SampException
Description copied from interface:HubConnection
Sends a message to a given client expecting a response. ThereceiveResponse
method of this connection'sCallableClient
will be called with a response at some time in the future.Only permitted if this client is already callable.
- Specified by:
call
in interfaceHubConnection
- Overrides:
call
in classWrapperHubConnection
- Parameters:
recipientId
- public-id of client to receive messagemsgTag
- arbitrary string tagging this message for caller's benefitmsg
-Message
-like map- Returns:
- message ID
- Throws:
SampException
-
callAll
public java.util.Map callAll(java.lang.String msgTag, java.util.Map msg) throws SampException
Description copied from interface:HubConnection
Sends a message to all subscribed clients expecting responses. ThereceiveResponse
method of this connection'sCallableClient
will be called with responses at some time in the future.Only permitted if this client is already callable.
- Specified by:
callAll
in interfaceHubConnection
- Overrides:
callAll
in classWrapperHubConnection
- Parameters:
msgTag
- arbitrary string tagging this message for caller's benefitmsg
-Message
-like map- Returns:
- public-id->msg-id map for clients to which an attempt to send the call will be made
- Throws:
SampException
-
callAndWait
public Response callAndWait(java.lang.String recipientId, java.util.Map msg, int timeout) throws SampException
Description copied from interface:HubConnection
Sends a message synchronously to a client, waiting for the response. If more seconds elapse than the value of thetimeout
parameter, an exception will result.- Specified by:
callAndWait
in interfaceHubConnection
- Overrides:
callAndWait
in classWrapperHubConnection
- Parameters:
recipientId
- public-id of client to receive messagemsg
-Message
-like maptimeout
- timeout in seconds, or <0 for no timeout- Returns:
- response
- Throws:
SampException
-
reply
public void reply(java.lang.String msgId, java.util.Map response) throws SampException
Description copied from interface:HubConnection
Supplies a response to a previously received message.- Specified by:
reply
in interfaceHubConnection
- Overrides:
reply
in classWrapperHubConnection
- Parameters:
msgId
- ID associated with earlier sendresponse
-Response
-like map- Throws:
SampException
-
setCallable
public void setCallable(CallableClient callable) throws SampException
Description copied from interface:HubConnection
Tells the hub how it can perform callbacks on the client by providing a CallableClient object. This is required before the client can declare subscriptions or make asynchronous calls.- Specified by:
setCallable
in interfaceHubConnection
- Overrides:
setCallable
in classWrapperHubConnection
- Parameters:
callable
- callable client- Throws:
SampException
-
-