public abstract class StreamBaseDevice extends GenericBaseDevice implements BaseDevice
| Modifier and Type | Field and Description |
|---|---|
static int |
CONNECT_TIMEOUT |
protected IoSession |
session |
connectionListeners| Constructor and Description |
|---|
StreamBaseDevice(SocketAddress address) |
| Modifier and Type | Method and Description |
|---|---|
void |
connect() |
void |
dispose() |
boolean |
isConnected() |
void |
sessionClosed(IoSession session)
Invoked when a connection is closed.
|
void |
sessionCreated(IoSession session)
Invoked from an I/O processor thread when a new connection has been created.
|
void |
sessionIdle(IoSession session,
IdleStatus status)
Invoked with the related
IdleStatus when a connection becomes idle. |
void |
sessionOpened(IoSession session)
Invoked when a connection has been opened.
|
protected void |
setTimeout(long timeout) |
protected abstract void |
setupConnector(SocketConnector connector) |
protected void |
writeMessage(Object message)
Write a message to the outbound connection or fail if there is not open
connection at the moment
|
protected void |
writeMessageIgnore(Object message)
Write a message to the outbound connection or ignore it if there is no
open connection at the moment
|
addConnectionListener, fireConnected, fireConnectionFailed, fireDisconnected, removeConnectionListenerexceptionCaught, messageReceived, messageSentclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddConnectionListener, removeConnectionListenerpublic static final int CONNECT_TIMEOUT
protected IoSession session
public StreamBaseDevice(SocketAddress address)
protected abstract void setupConnector(SocketConnector connector)
public boolean isConnected()
isConnected in interface BaseDevicepublic void connect()
connect in interface BaseDevicepublic void dispose()
dispose in interface BaseDevicepublic void sessionCreated(IoSession session) throws Exception
IoHandlersessionCreated in interface IoHandlersessionCreated in class IoHandlerAdapterExceptionprotected void setTimeout(long timeout)
public void sessionOpened(IoSession session) throws Exception
IoHandlerIoHandler.sessionCreated(IoSession). The biggest difference from
IoHandler.sessionCreated(IoSession) is that it's invoked from other thread
than an I/O processor thread once thread model is configured properly.sessionOpened in interface IoHandlersessionOpened in class IoHandlerAdapterExceptionpublic void sessionIdle(IoSession session, IdleStatus status) throws Exception
IoHandlerIdleStatus when a connection becomes idle.
This method is not invoked if the transport type is UDP; it's a known bug,
and will be fixed in 2.0.sessionIdle in interface IoHandlersessionIdle in class IoHandlerAdapterExceptionpublic void sessionClosed(IoSession session) throws Exception
IoHandlersessionClosed in interface IoHandlersessionClosed in class IoHandlerAdapterExceptionprotected void writeMessage(Object message) throws NotConnectedException
message - the message to wrtiteNotConnectedException - thrown if there is no connection at the momentprotected void writeMessageIgnore(Object message)
message - the message to write