public class Client extends Object
| Modifier and Type | Field and Description |
|---|---|
static int[] |
DEFAULT_DATAGRAM_PORTS
The default ports on which the server listens for datagrams.
|
static int |
DEFAULT_MSGS_PER_SECOND
Our default maximum outgoing message rate in messages per second.
|
static int[] |
DEFAULT_SERVER_PORTS
The default ports on which the server listens for client connections.
|
static int |
MAX_DATAGRAM_SIZE
The maximum size of a datagram.
|
| Constructor and Description |
|---|
Client(Credentials creds,
RunQueue runQueue)
Constructs a client object with the supplied credentials and RunQueue.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClientObserver(SessionObserver observer)
Registers the supplied observer with this client.
|
void |
addServiceGroup(String group)
Marks this client as interested in the specified bootstrap services group.
|
void |
fieldsToString(StringBuilder builder)
Adds text representation of fields to the builder.
|
long |
fromServerTime(long stamp)
Converts a server time stamp to a value comparable to client clock readings.
|
AuthResponseData |
getAuthResponseData()
Returns the data associated with our authentication response.
|
String[] |
getBootGroups()
Returns the set of bootstrap service groups needed by this client.
|
BootstrapData |
getBootstrapData()
Returns a reference to the bootstrap data provided to this client at logon time.
|
ClientObject |
getClientObject()
Returns a reference to the client object associated with this session.
|
int |
getClientOid()
Returns the oid of the client object associated with this session.
|
int |
getConnectionId()
Returns the unique id of the client's connection to the server.
|
Credentials |
getCredentials()
Returns the credentials with which this client is currently configured to connect to the
server.
|
int[] |
getDatagramPorts()
Returns the ports on the server to which the client can send datagrams.
|
DObjectManager |
getDObjectManager()
Returns the distributed object manager associated with this session.
|
String |
getHostname()
Returns the hostname of the server to which this client is currently configured to connect.
|
InvocationDirector |
getInvocationDirector()
Returns the invocation director associated with this session.
|
int[] |
getPorts()
Returns the port on which this client is currently configured to connect to the server.
|
PublicKey |
getPublicKey()
Returns the public key with which this client is currently configured to create a secure
authentication channel to the server.
|
RunQueue |
getRunQueue()
Returns the RunQueue in use by this client.
|
byte[] |
getSecret()
Gets the secret key to use with a session.
|
<T> T |
getService(Class<T> sclass)
Returns the first bootstrap service that could be located that implements the supplied
InvocationService derivation. |
boolean |
getTransmitDatagrams()
Checks whether we should transmit datagrams.
|
String |
getVersion()
Returns the version string configured for this client.
|
boolean |
isActive()
Returns true if we are in active communication (we may not yet be logged on, but we could be
trying to log on).
|
boolean |
isLoggedOn()
Returns true if we are logged on, false if we're not.
|
boolean |
isStandalone()
Checks whether or not this client is operating in a standalone mode.
|
boolean |
logoff(boolean abortable)
Requests that the client log off of the server to which it is connected.
|
boolean |
logon()
Requests that this client connect and logon to the server with which it was previously
configured.
|
void |
moveToServer(String hostname,
int[] ports,
int[] datagramPorts,
InvocationService.ConfirmListener obs)
Transitions a logged on client from its current server to the specified new server.
|
void |
moveToServer(String hostname,
int[] ports,
InvocationService.ConfirmListener obs)
Transitions a logged on client from its current server to the specified new server.
|
String[] |
prepareStandaloneLogon()
Prepares the client for a standalone mode logon.
|
void |
registerFlushDelay(Class<?> objclass,
long delay)
Instructs the distributed object manager associated with this client to allow objects of the
specified class to linger around the specified number of milliseconds after their last
subscriber has been removed before the client finally removes its object proxy and flushes
the object.
|
void |
removeClientObserver(SessionObserver observer)
Unregisters the supplied observer.
|
boolean |
requireSecureAuth()
Returns true if we require secure authentication.
|
<T> T |
requireService(Class<T> sclass)
Like
getService(java.lang.Class<T>) except that a RuntimeException is thrown if the service is
not available. |
void |
setClassLoader(ClassLoader loader)
Configures the client with a custom class loader which will be used when reading objects off
of the network.
|
void |
setCredentials(Credentials creds)
Sets the credentials that will be used by this client to authenticate with the server.
|
void |
setMessageTracker(MessageTracker tracker)
Installs (or clears) a message tracker that will be notified on message transmission and
receipt for the purpose of statistics tracking.
|
boolean |
setPublicKey(PublicKey key)
Sets the public key that will be used by this client to create a secure authentication
channel with the server if the ciphers are supported.
|
boolean |
setPublicKey(String key)
Sets the public key that will be used by this client to create a secure authentication
channel with the server if the ciphers are supported.
|
void |
setRequireSecureAuth(boolean requireSecureAuth)
Sets if we require a secure authentication.
|
void |
setSecret(byte[] secret)
Sets the secret key to use with a session.
|
void |
setServer(String hostname,
int[] ports)
Configures the client to communicate with the server on the supplied hostname and set of
ports (which will be tried in succession).
|
void |
setServer(String hostname,
int[] ports,
int[] datagramPorts)
Configures the client to communicate with the server on the supplied hostname, set of
ports (which will be tried in succession), and datagram ports.
|
void |
setVersion(String version)
Sets the version string reported to the server during authentication.
|
void |
standaloneLogoff()
For standalone mode, this notifies observers that the client has logged off and cleans up.
|
void |
standaloneLogon(BootstrapData data,
DObjectManager omgr)
Logs this client on in standalone mode with the faked bootstrap data and shared local
distributed object manager.
|
long |
toServerTime(long stamp)
Converts a client clock reading to a value comparable to a server time stamp.
|
String |
toString() |
public static final int[] DEFAULT_SERVER_PORTS
public static final int[] DEFAULT_DATAGRAM_PORTS
public static final int MAX_DATAGRAM_SIZE
public static final int DEFAULT_MSGS_PER_SECOND
public Client(Credentials creds, RunQueue runQueue)
creds - the credentials to use when logging on to the server. These can be null, but
setCredentials must then be called before any call to logon.runQueue - a RunQueue that can be used to process incoming events.public void addClientObserver(SessionObserver observer)
ClientObserver,
SessionObserverpublic void removeClientObserver(SessionObserver observer)
public boolean isStandalone()
public void setServer(String hostname, int[] ports)
public void setServer(String hostname, int[] ports, int[] datagramPorts)
public RunQueue getRunQueue()
public String getHostname()
public int[] getPorts()
public int[] getDatagramPorts()
public Credentials getCredentials()
public void setCredentials(Credentials creds)
logon.public PublicKey getPublicKey()
public boolean setPublicKey(PublicKey key)
logon.public boolean setPublicKey(String key)
logon.public void setRequireSecureAuth(boolean requireSecureAuth)
public boolean requireSecureAuth()
public void setSecret(byte[] secret)
public byte[] getSecret()
public String getVersion()
public void setVersion(String version)
public void setClassLoader(ClassLoader loader)
public void setMessageTracker(MessageTracker tracker)
tracker - the new tracker to install, or null to clear the tracker.public AuthResponseData getAuthResponseData()
AuthResponseData.public DObjectManager getDObjectManager()
public void registerFlushDelay(Class<?> objclass, long delay)
Note: the delay will be applied to derived classes as well as exact matches. Note also: this method cannot be called until after the client has established a connection with the server and the distributed object manager is available.
public int getConnectionId()
public int getClientOid()
public ClientObject getClientObject()
public InvocationDirector getInvocationDirector()
public void addServiceGroup(String group)
logon().public String[] getBootGroups()
public <T> T getService(Class<T> sclass)
InvocationService derivation. null is returned if no such service
could be found.public <T> T requireService(Class<T> sclass)
getService(java.lang.Class<T>) except that a RuntimeException is thrown if the service is
not available. Useful to avoid redundant error checking when you know that the shit will hit
the fan if a particular invocation service is not available.public BootstrapData getBootstrapData()
public long fromServerTime(long stamp)
public long toServerTime(long stamp)
public boolean isActive()
public boolean getTransmitDatagrams()
public boolean isLoggedOn()
public boolean logon()
public void moveToServer(String hostname, int[] ports, InvocationService.ConfirmListener obs)
If we fail to connect to the new server, the client will not be automatically
reconnected to the old server. It will be in a logged off state. However, it will be
reconfigured with the hostname and ports of the old server so that the caller can notify the
user of the failure and then simply call logon() to attempt to reconnect to the old
server.
obs - an observer that will be notified when we have successfully logged onto the
other server, or if the move failed.public void moveToServer(String hostname, int[] ports, int[] datagramPorts, InvocationService.ConfirmListener obs)
If we fail to connect to the new server, the client will not be automatically
reconnected to the old server. It will be in a logged off state. However, it will be
reconfigured with the hostname and ports of the old server so that the caller can notify the
user of the failure and then simply call logon() to attempt to reconnect to the old
server.
obs - an observer that will be notified when we have successfully logged onto the
other server, or if the move failed.public boolean logoff(boolean abortable)
abortable - If true, the client will call clientWillDisconnect on all of
the client observers and abort the logoff process if any of them return false. If false,
clientWillDisconnect will not be called at all.public String[] prepareStandaloneLogon()
public void standaloneLogon(BootstrapData data, DObjectManager omgr)
public void standaloneLogoff()
public void fieldsToString(StringBuilder builder)
toString.Copyright © 2015. All rights reserved.