public abstract class ClientNetworkAdapter<C extends ClientContext> extends AbstractClientObject<C> implements NetworkConnectionEvent.Source
ClientRequestConnection
and ClientMessageConnection
maintaining them
together as a session. Note that the messageConnection is the reference for the connected-state. It is established
AFTER the requestConnection and used as synchronization point for a disconnect. Furthermore it is the only connection
that is able to detect a connection loss.Constructor and Description |
---|
ClientNetworkAdapter(C clientCtx,
ServerHost serverHost,
StreamWrapper streamWrapper) |
Modifier and Type | Method and Description |
---|---|
void |
addNetworkConnectionListener(NetworkConnectionEvent.Listener l) |
void |
checkConnected() |
void |
confirmResponse() |
void |
connect() |
protected abstract ClientMessageConnection |
createMessageConnection(LogChannel logCh,
ServerHost serverHost,
StreamWrapper streamWrapper) |
protected abstract ClientRequestConnection |
createRequestConnection(LogChannel logCh,
ServerHost serverHost,
StreamWrapper streamWrapper,
VersionCheck versionCheck) |
boolean |
disconnect() |
java.lang.String |
getClientConnectionInfo() |
java.sql.Timestamp |
getConnectedSinceTs()
Returns the timestamp of the last connection or null if the client is disconnected.
|
java.lang.String |
getServerConnectionInfo() |
ServerHost |
getServerHost() |
ServerId |
getServerId() |
SessionId |
getSessionId() |
boolean |
isConnected()
Actually returns the state of the messageConnection, which is the reference
for the connected-state.
|
boolean |
isLoggedIn() |
boolean |
isReceivingMessages() |
void |
removeNetworkConnectionListener(NetworkConnectionEvent.Listener l) |
void |
sendClientTimeoutTest()
For testing purposes only
|
NetResponse |
sendRequest(NetRequest request)
Sends a
NetRequest object to the server and returns the NetResponse object to the client. |
void |
setConnectionTimeout(int timeoutSeconds) |
void |
setMessageDispatcher(ClientMessageHandler messageDispatcher)
Sets the handler
ClientMessageHandler for dispatching incoming messages. |
void |
shutdown()
This method is called when a connection loss is discovered by the message receive thread.
|
getClientConfig, getClientContext
getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString
public ClientNetworkAdapter(C clientCtx, ServerHost serverHost, StreamWrapper streamWrapper)
public void setMessageDispatcher(ClientMessageHandler messageDispatcher)
ClientMessageHandler
for dispatching incoming messages.public final void confirmResponse() throws java.lang.Exception
java.lang.Exception
public final ServerHost getServerHost()
public final ServerId getServerId()
public final boolean isConnected()
public final SessionId getSessionId()
public final java.lang.String getClientConnectionInfo()
public final java.lang.String getServerConnectionInfo()
public final boolean isLoggedIn()
public final void connect() throws java.lang.Exception
java.lang.Exception
public final void setConnectionTimeout(int timeoutSeconds)
public final boolean isReceivingMessages()
public final boolean disconnect()
public final void shutdown()
public final java.sql.Timestamp getConnectedSinceTs()
public final NetResponse sendRequest(NetRequest request) throws java.lang.Exception
NetRequest
object to the server and returns the NetResponse
object to the client. Note
that the response object is guaranteed not to be null but it must be checked for errors with the hasError()
method.java.lang.Exception
public void checkConnected() throws ClientNotConnectedException
ClientNotConnectedException
public final void sendClientTimeoutTest() throws java.lang.Exception
java.lang.Exception
public final void addNetworkConnectionListener(NetworkConnectionEvent.Listener l)
addNetworkConnectionListener
in interface NetworkConnectionEvent.Source
public final void removeNetworkConnectionListener(NetworkConnectionEvent.Listener l)
removeNetworkConnectionListener
in interface NetworkConnectionEvent.Source
protected abstract ClientRequestConnection createRequestConnection(LogChannel logCh, ServerHost serverHost, StreamWrapper streamWrapper, VersionCheck versionCheck)
protected abstract ClientMessageConnection createMessageConnection(LogChannel logCh, ServerHost serverHost, StreamWrapper streamWrapper)
Copyright © 2014 EsprIT-Systems. All Rights Reserved.