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 ClientselfClient_
-
Constructor Summary
Constructors Constructor Description MessageTrackerHubConnection(HubConnection base)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringcall(java.lang.String recipientId, java.lang.String msgTag, java.util.Map msg)Sends a message to a given client expecting a response.java.util.MapcallAll(java.lang.String msgTag, java.util.Map msg)Sends a message to all subscribed clients expecting responses.ResponsecallAndWait(java.lang.String recipientId, java.util.Map msg, int timeout)Sends a message synchronously to a client, waiting for the response.(package private) ClientgetSelfClient()Returns a Client object for use in Transmission objects which represents this connection's owner.voidnotify(java.lang.String recipientId, java.util.Map msg)Sends a message to a given client without wanting a response.java.util.ListnotifyAll(java.util.Map msg)Sends a message to all subscribed clients without wanting a response.voidreply(java.lang.String msgId, java.util.Map response)Supplies a response to a previously received message.voidsetCallable(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 SampExceptionDescription copied from interface:HubConnectionSends a message to a given client without wanting a response.- Specified by:
notifyin interfaceHubConnection- Overrides:
notifyin 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 SampExceptionDescription copied from interface:HubConnectionSends a message to all subscribed clients without wanting a response.- Specified by:
notifyAllin interfaceHubConnection- Overrides:
notifyAllin 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 SampExceptionDescription copied from interface:HubConnectionSends a message to a given client expecting a response. ThereceiveResponsemethod of this connection'sCallableClientwill be called with a response at some time in the future.Only permitted if this client is already callable.
- Specified by:
callin interfaceHubConnection- Overrides:
callin 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 SampExceptionDescription copied from interface:HubConnectionSends a message to all subscribed clients expecting responses. ThereceiveResponsemethod of this connection'sCallableClientwill be called with responses at some time in the future.Only permitted if this client is already callable.
- Specified by:
callAllin interfaceHubConnection- Overrides:
callAllin 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:HubConnectionSends a message synchronously to a client, waiting for the response. If more seconds elapse than the value of thetimeoutparameter, an exception will result.- Specified by:
callAndWaitin interfaceHubConnection- Overrides:
callAndWaitin 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 SampExceptionDescription copied from interface:HubConnectionSupplies a response to a previously received message.- Specified by:
replyin interfaceHubConnection- Overrides:
replyin 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:HubConnectionTells 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:
setCallablein interfaceHubConnection- Overrides:
setCallablein classWrapperHubConnection- Parameters:
callable- callable client- Throws:
SampException
-
-