public abstract class ClientBaseConnection extends BaseConnection implements Connection
| Modifier and Type | Field and Description |
|---|---|
protected CallbackFactory |
callbackFactory |
protected CallbackHandler |
connectCallbackHandler |
connectionInformation, executor, statistics| Constructor and Description |
|---|
ClientBaseConnection(IoHandlerFactory handlerFactory,
IoLoggerFilterChainBuilder chainBuilder,
ConnectionInformation connectionInformation) |
| Modifier and Type | Method and Description |
|---|---|
void |
addConnectionStateListener(ConnectionStateListener connectionStateListener) |
void |
addPrivilegeListener(PrivilegeListener listener)
Add a listener to the privileges of the session
|
void |
connect()
Start the connection
|
void |
connect(CallbackHandler callbackHandler)
Start the connection with a callback handler
|
void |
disconnect()
Stop the connection
|
void |
dispose()
Dispose the connection
|
protected void |
firePrivilegeChange(Set<String> granted) |
Set<String> |
getPrivileges()
Return the list of currently granted privileges.
|
protected IoSession |
getSession() |
SSLSession |
getSslSession() |
ConnectionState |
getState()
Get the current connection state
|
protected void |
handleConnectComplete(ConnectFuture future) |
protected abstract void |
handleMessage(Object message)
Handle a message that came in by the current session.
|
boolean |
isDisposed() |
void |
messageReceived(IoSession session,
Object message) |
protected void |
onConnectionBound()
Called when the connection got bound
|
protected void |
onConnectionClosed()
Called when the connection got closed
|
protected void |
onConnectionConnected()
Called when the connection got connected
|
protected void |
performClosed(IoSession session,
Throwable error) |
protected void |
performDisconnected(Throwable error) |
void |
performOpened(IoSession session) |
void |
removeConnectionStateListener(ConnectionStateListener connectionStateListener) |
void |
removePrivilegeListener(PrivilegeListener listener) |
protected void |
sendMessage(Object message) |
protected void |
sendMessageChecked(Object message)
Send a message if a connection exists
|
void |
setCallbackFactory(CallbackFactory callbackFactory) |
protected void |
setState(ConnectionState connectionState,
Throwable error) |
protected void |
switchState(ConnectionState state,
Throwable error) |
getConnectionInformation, getSessionProperties, getStatistics, setSessionPropertiesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConnectionInformation, getSessionPropertiesprotected volatile CallbackHandler connectCallbackHandler
protected CallbackFactory callbackFactory
public ClientBaseConnection(IoHandlerFactory handlerFactory, IoLoggerFilterChainBuilder chainBuilder, ConnectionInformation connectionInformation) throws Exception
Exceptionpublic void setCallbackFactory(CallbackFactory callbackFactory)
setCallbackFactory in interface Connectionpublic void connect()
Connectionconnect in interface Connectionpublic void connect(CallbackHandler callbackHandler)
Connectionconnect in interface Connectionpublic void disconnect()
Connectiondisconnect in interface Connectionprotected void switchState(ConnectionState state, Throwable error)
protected void onConnectionBound()
This method is called while the connection lock is held.
The default implementation does nothing.
protected void onConnectionConnected()
This method is called while the connection lock is held.
The default implementation switches directly to
ConnectionState.BOUND
protected void onConnectionClosed()
This method is called while the connection lock is held.
The default implementation does nothing.
protected void performDisconnected(Throwable error)
protected void handleConnectComplete(ConnectFuture future)
public boolean isDisposed()
public void dispose()
ConnectionA dispose will also act as a disconnect.
Connections must be disposed in order to clean up all resources. In the
past the Connection.disconnect() call was enough and, if possible, most
resources (sockets) should be closed when disconnecting. Still some
resources can be re-used and these need to be cleaned up in the
Connection.dispose() call.
dispose in interface Connectiondispose in class BaseConnectionprotected void setState(ConnectionState connectionState, Throwable error)
public void addConnectionStateListener(ConnectionStateListener connectionStateListener)
addConnectionStateListener in interface Connectionpublic void removeConnectionStateListener(ConnectionStateListener connectionStateListener)
removeConnectionStateListener in interface Connectionpublic ConnectionState getState()
ConnectiongetState in interface Connectionpublic void performOpened(IoSession session)
protected abstract void handleMessage(Object message)
Note that the method is called while holding the lock the connection itself.
message - the received messageprotected void sendMessageChecked(Object message) throws NoConnectionException
Works like sendMessage(Object), but the connection is not
established it will throw an exception instead of silently ignoring the
fact.
message - the message to sendNoConnectionException - thrown in case no connection currently existsprotected void sendMessage(Object message)
public SSLSession getSslSession()
public void addPrivilegeListener(PrivilegeListener listener)
ConnectionWhen adding a new listener it will receive an initial call with the current privileges.
addPrivilegeListener in interface Connectionpublic void removePrivilegeListener(PrivilegeListener listener)
removePrivilegeListener in interface Connectionpublic Set<String> getPrivileges()
ConnectiongetPrivileges in interface Connectionnull.protected IoSession getSession()