class ProxyManager
extends java.lang.Object
init(org.astrogrid.samp.bridge.ProxyManager[])
).Modifier and Type | Class and Description |
---|---|
private class |
ProxyManager.ProxyCallableClient
CallableClient implementation used by remote proxy connections on
behalf of local clients.
|
private class |
ProxyManager.ProxyIconAdjuster
Class which can turn a client's icon into the icon for the proxy of
the same client.
|
private class |
ProxyManager.ProxyManagerClientSet
TrackedClientSet implementation used by a Proxy Manager.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map |
connectionMap_ |
private UrlExporter |
exporter_ |
private IconAdjuster |
iconAdjuster_ |
private ClientProfile |
localProfile_ |
private static java.util.logging.Logger |
logger_ |
private int |
nRemote_ |
private HubConnector |
pmConnector_ |
private ProxyManager[] |
remoteManagers_ |
private UtilServer |
server_ |
private java.util.Map |
tagMap_ |
private boolean |
useProxyHub_ |
Constructor and Description |
---|
ProxyManager(ClientProfile localProfile,
UtilServer server)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
HubConnector |
getManagerConnector()
Returns the hub connector used by this manager for client monitoring
on the local hub.
|
private int |
getManagerIndex(ProxyManager remoteManager)
Returns the index by which this manager labels a given remote
proxy manager.
|
ClientProfile |
getProfile()
Returns the profile for this manager's local hub.
|
private HubConnection |
getProxyConnection(ProxyManager remoteManager,
java.lang.String localClientId)
Returns the connection on the hub associated with a remote
proxy manager which is the proxy for a given local client.
|
private Metadata |
getProxyMetadata(Client localClient)
Returns the metadata to use for the remote proxy of a local client.
|
private Subscriptions |
getProxySubscriptions(Client client)
Returns the subscriptions to use for the remote proxy of a local client.
|
void |
init(ProxyManager[] allManagers)
Prepares this manager for use by informing it about all its sibling
managers.
|
private boolean |
isProxiedClient(Client client)
Determines whether a local client is a genuine third party client
which requires a remote proxy.
|
private boolean |
isProxy(Client client,
ProxyManager remoteManager)
Determines whether a given local client is a proxy controlled by
a given remote ProxyManager.
|
private void |
localClientAdded(Client client)
Invoked when a client is added to the local hub.
|
private void |
localClientRemoved(Client client)
Invoked when a client is removed from the local hub.
|
private void |
localClientUpdated(Client client,
boolean metaChanged,
boolean subsChanged)
Invoked when information (metadata or subscriptions) have been
updated for a client on the local hub.
|
protected void |
managerConnectionChanged(boolean isConnected)
Called when this ProxyManager's connector has been disconnected
(for whatever reason) from its local hub.
|
private java.net.URL |
proxyIconUrl(java.net.URL localIconUrl)
Returns the icon to be used for a proxy client given its local icon.
|
private java.lang.String |
proxyName(java.lang.String localName)
Returns the name to be used for a proxy client given its local name.
|
private void |
removeProxyConnection(ProxyManager remoteManager,
java.lang.String localClientId)
Deletes the record of the connection on the hub associated with
a remote proxy manager which is the proxy for a given local client.
|
void |
setExporter(UrlExporter exporter)
Sets an object which is used to export SAMP data contents for use
in remote contexts.
|
void |
setUseProxyHub(boolean useProxyHub)
Sets whether remote proxy should be generated for the local client
representing the local hub.
|
java.lang.String |
toString() |
private final ClientProfile localProfile_
private final UtilServer server_
private final HubConnector pmConnector_
private final java.util.Map connectionMap_
private final java.util.Map tagMap_
private final IconAdjuster iconAdjuster_
private ProxyManager[] remoteManagers_
private UrlExporter exporter_
private boolean useProxyHub_
private int nRemote_
private static final java.util.logging.Logger logger_
public ProxyManager(ClientProfile localProfile, UtilServer server)
localProfile
- profile for connection to this manager's local hubserver
- server instancepublic ClientProfile getProfile()
public HubConnector getManagerConnector()
public void setExporter(UrlExporter exporter)
exporter
- new exporter; may be nullpublic void setUseProxyHub(boolean useProxyHub)
useProxyHub
- true iff the client representing the local hub
should be proxied remotelypublic void init(ProxyManager[] allManagers)
allManagers
- array of ProxyManagers including this one,
one for each hub participating in the bridgepublic java.lang.String toString()
toString
in class java.lang.Object
private HubConnection getProxyConnection(ProxyManager remoteManager, java.lang.String localClientId)
remoteManager
- proxy manager for a remote bridged hublocalClientId
- client ID of a client registered with
this manager's local hubprivate void removeProxyConnection(ProxyManager remoteManager, java.lang.String localClientId)
remoteManager
- proxy manager for a remote bridged hublocalClientId
- client ID of a client registered with
this manager's local hubprivate int getManagerIndex(ProxyManager remoteManager)
remoteManager
- manager to locateremoteManager
in the listprivate Metadata getProxyMetadata(Client localClient)
localClient
- local clientprivate java.lang.String proxyName(java.lang.String localName)
localName
- local nameprivate java.net.URL proxyIconUrl(java.net.URL localIconUrl)
localIconUrl
- URL for local iconprivate Subscriptions getProxySubscriptions(Client client)
localClient
- local clientprotected void managerConnectionChanged(boolean isConnected)
isConnected
- true for a connection; false for a disconnectionprivate void localClientAdded(Client client)
client
- newly added clientprivate void localClientRemoved(Client client)
client
- recently removed clientprivate void localClientUpdated(Client client, boolean metaChanged, boolean subsChanged)
client
- updated clientmetaChanged
- true if metadata may have changed
(false if known unchanged)subsChanged
- true if subscriptions may have changed
(false if known unchanged)private boolean isProxiedClient(Client client)
client
- local clienttrue
- if client
has or should have a proxy;
false if it's an organ of the bridge administrationprivate boolean isProxy(Client client, ProxyManager remoteManager)
client
- local clientremoteManager
- remote proxy managerclient
is one of
remoteManager
's proxies