public class SslConnectionHandler extends Object implements ConnectionHandler, ReadContext, HeartBeatContext
ConnectionHandler
.Constructor and Description |
---|
SslConnectionHandler(Connection connection,
SSLEngine engine,
SslTaskExecutor taskExecutor,
int sendBufferSize,
CommunicationProtocol wrappedCommunicationProtocol)
Initiate.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getData()
Obtains the data just read to be consumed by the
ConnectionHandler . |
long |
getTime()
Obtains the current time in milliseconds.
|
void |
handleHeartbeat(HeartBeatContext context)
Handles a heart beat on
Connection . |
void |
handleRead(ReadContext context)
Handles a read from the
SocketChannel . |
public SslConnectionHandler(Connection connection, SSLEngine engine, SslTaskExecutor taskExecutor, int sendBufferSize, CommunicationProtocol wrappedCommunicationProtocol)
connection
- Connection
.engine
- SSLEngine
.taskExecutor
- SslTaskExecutor
.sendBufferSize
- Send buffer size.wrappedCommunicationProtocol
- Wrapped CommunicationProtocol
.public void handleRead(ReadContext context) throws IOException
ConnectionHandler
SocketChannel
.handleRead
in interface ConnectionHandler
context
- ReadContext
.IOException
- If fails to obtain data from the ReadContext
.public void handleHeartbeat(HeartBeatContext context) throws IOException
ConnectionHandler
Handles a heart beat on Connection
.
Typical use of the heart beat is to allow the ConnectionHandler
to close an idle Connection
.
handleHeartbeat
in interface ConnectionHandler
context
- HeartBeatContext
.IOException
- If fails to handle heart beat. Possibly from attempting to
close it.public long getTime()
ConnectionHandlerContext
Obtains the current time in milliseconds.
This should return similar to System.currentTimeMillis()
but is
provided to cache time for multiple quick operations that require only
estimates of time (e.g. time out idle connections in seconds).
Note CPU operations should be in the nanoseconds.
getTime
in interface ConnectionHandlerContext
public byte[] getData()
ReadContext
Obtains the data just read to be consumed by the
ConnectionHandler
.
The returned array is always new and must be consumed (or stored to be
consumed) by the ConnectionHandler
.
getData
in interface ReadContext
ConnectionHandler
.Copyright © 2005–2016. All rights reserved.