public abstract class StreamIoHandler extends IoHandlerAdapter
IoHandler that adapts asynchronous MINA events to stream I/O.
Please extend this class and implement processStreamIo(IoSession, InputStream, OutputStream) to execute your stream I/O logic; please note that you must forward the process request to other thread or thread pool.
| Modifier | Constructor and Description |
|---|---|
protected |
StreamIoHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
exceptionCaught(IoSession session,
Throwable cause)
Forwards caught exceptions to input stream.
|
int |
getReadTimeout() |
int |
getWriteTimeout() |
void |
messageReceived(IoSession session,
Object buf)
Forwards read data to input stream.
|
protected abstract void |
processStreamIo(IoSession session,
InputStream in,
OutputStream out)
Implement this method to execute your stream I/O logic;
please note that you must forward the process request to other
thread or thread pool.
|
void |
sessionClosed(IoSession session)
Closes streams
|
void |
sessionIdle(IoSession session,
IdleStatus status)
Handles read timeout.
|
void |
sessionOpened(IoSession session)
Initializes streams and timeout settings.
|
void |
setReadTimeout(int readTimeout)
Sets read timeout in seconds.
|
void |
setWriteTimeout(int writeTimeout)
Sets write timeout in seconds.
|
event, inputClosed, messageSent, sessionCreatedprotected abstract void processStreamIo(IoSession session, InputStream in, OutputStream out)
session - The current sessionin - The input streamout - The output streampublic int getReadTimeout()
0 (disabled).public void setReadTimeout(int readTimeout)
0 (disabled).readTimeout - The Read timeoutpublic int getWriteTimeout()
0 (disabled).public void setWriteTimeout(int writeTimeout)
0 (disabled).writeTimeout - The Write timeoutpublic void sessionOpened(IoSession session)
sessionOpened in interface IoHandlersessionOpened in class IoHandlerAdaptersession - The session being openedpublic void sessionClosed(IoSession session) throws Exception
sessionClosed in interface IoHandlersessionClosed in class IoHandlerAdaptersession - The session being closedException - If we get an exception while processing the close eventpublic void messageReceived(IoSession session, Object buf)
messageReceived in interface IoHandlermessageReceived in class IoHandlerAdaptersession - The session that is receiving a messagebuf - The received messagepublic void exceptionCaught(IoSession session, Throwable cause)
exceptionCaught in interface IoHandlerexceptionCaught in class IoHandlerAdaptersession - The session for which we have got an exceptioncause - The exception that has been caughtpublic void sessionIdle(IoSession session, IdleStatus status)
sessionIdle in interface IoHandlersessionIdle in class IoHandlerAdaptersession - The idling sessionstatus - The session's statusCopyright © 2004–2024 Apache MINA Project. All rights reserved.