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, removeConnectionListener
exceptionCaught, messageReceived, messageSent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addConnectionListener, removeConnectionListener
public static final int CONNECT_TIMEOUT
protected IoSession session
public StreamBaseDevice(SocketAddress address)
protected abstract void setupConnector(SocketConnector connector)
public boolean isConnected()
isConnected
in interface BaseDevice
public void connect()
connect
in interface BaseDevice
public void dispose()
dispose
in interface BaseDevice
public void sessionCreated(IoSession session) throws Exception
IoHandler
sessionCreated
in interface IoHandler
sessionCreated
in class IoHandlerAdapter
Exception
protected void setTimeout(long timeout)
public void sessionOpened(IoSession session) throws Exception
IoHandler
IoHandler.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 IoHandler
sessionOpened
in class IoHandlerAdapter
Exception
public void sessionIdle(IoSession session, IdleStatus status) throws Exception
IoHandler
IdleStatus
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 IoHandler
sessionIdle
in class IoHandlerAdapter
Exception
public void sessionClosed(IoSession session) throws Exception
IoHandler
sessionClosed
in interface IoHandler
sessionClosed
in class IoHandlerAdapter
Exception
protected 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