Package org.astrogrid.samp.bridge
Class ProxyManager.ProxyCallableClient
- java.lang.Object
-
- org.astrogrid.samp.bridge.ProxyManager.ProxyCallableClient
-
- All Implemented Interfaces:
CallableClient
- Enclosing class:
- ProxyManager
private class ProxyManager.ProxyCallableClient extends java.lang.Object implements CallableClient
CallableClient implementation used by remote proxy connections on behalf of local clients. This is the core of the proxy manager. Callbacks received by the remote proxy client are tunnelled back to the local hub and forwarded by the local proxy of the remote sender client to the appropriate local non-proxy client. Since local proxies are managed by other proxy managers (this one manages remote proxies of local clients) this means getting the other proxy managers to do some of the work.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
localClientId_
private ProxyManager
localManager_
private ProxyManager
remoteManager_
private HubConnection
remoteProxy_
-
Constructor Summary
Constructors Constructor Description ProxyCallableClient(Client localClient, HubConnection remoteProxy, ProxyManager remoteManager)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private HubConnection
getLocalProxy(java.lang.String remoteClientId)
Returns the hub connection for the proxy on the local hub which corresponds to a given remote client.private void
proxyProcessMessage(java.lang.String remoteSenderId, Message msg)
Performs housekeeping tasks for an incoming message if any.void
receiveCall(java.lang.String remoteSenderId, java.lang.String remoteMsgId, Message msg)
Receives a message for which a response is required.void
receiveNotification(java.lang.String remoteSenderId, Message msg)
Receives a message for which no response is required.void
receiveResponse(java.lang.String remoteResponderId, java.lang.String remoteMsgTag, Response response)
Receives a response to a message previously sent by this client.
-
-
-
Field Detail
-
localClientId_
private final java.lang.String localClientId_
-
remoteProxy_
private final HubConnection remoteProxy_
-
remoteManager_
private final ProxyManager remoteManager_
-
localManager_
private final ProxyManager localManager_
-
-
Constructor Detail
-
ProxyCallableClient
ProxyCallableClient(Client localClient, HubConnection remoteProxy, ProxyManager remoteManager)
Constructor.- Parameters:
localClient
- local clientremoteProxy
- hub connection to the remote hub for the proxyremoteManager
- remote ProxyManager associated with the hub where this proxy is connected
-
-
Method Detail
-
receiveNotification
public void receiveNotification(java.lang.String remoteSenderId, Message msg) throws SampException
Description copied from interface:CallableClient
Receives a message for which no response is required.- Specified by:
receiveNotification
in interfaceCallableClient
- Parameters:
remoteSenderId
- public ID of sending clientmsg
- message- Throws:
SampException
-
receiveCall
public void receiveCall(java.lang.String remoteSenderId, java.lang.String remoteMsgId, 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:
remoteSenderId
- public ID of sending clientremoteMsgId
- message identifier for later use with replymsg
- message- Throws:
SampException
-
receiveResponse
public void receiveResponse(java.lang.String remoteResponderId, java.lang.String remoteMsgTag, 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:
remoteResponderId
- public ID of responding clientremoteMsgTag
- client-defined tag labelling previously-sent messageresponse
- returned response object- Throws:
SampException
-
getLocalProxy
private HubConnection getLocalProxy(java.lang.String remoteClientId)
Returns the hub connection for the proxy on the local hub which corresponds to a given remote client.- Parameters:
remoteClientId
- client ID of remote client- Returns:
- hub connection for local proxy
-
proxyProcessMessage
private void proxyProcessMessage(java.lang.String remoteSenderId, Message msg)
Performs housekeeping tasks for an incoming message if any. This is in addition to forwarding the message to the client for which we are proxying.- Parameters:
remoteSenderId
- id of sending client on remote hubmsg
- message
-
-