Class NIOTcpPacketTransport
- java.lang.Object
-
- net.timewalker.ffmq4.transport.AbstractPacketTransport
-
- net.timewalker.ffmq4.transport.tcp.AbstractTcpPacketTransport
-
- net.timewalker.ffmq4.transport.tcp.nio.NIOTcpPacketTransport
-
- All Implemented Interfaces:
PacketTransport,NIOClientSocketHandler
public final class NIOTcpPacketTransport extends AbstractTcpPacketTransport implements NIOClientSocketHandler
NIOTcpPacketTransport
-
-
Field Summary
Fields Modifier and Type Field Description protected longlastRecvActivityprotected longlastSendActivityprotected static org.apache.commons.logging.Loglog-
Fields inherited from class net.timewalker.ffmq4.transport.tcp.AbstractTcpPacketTransport
initialPacketBufferSize, pingInterval, sendQueueMaxSize, socketRecvBufferSize, socketSendBufferSize, streamRecvBufferSize, streamSendBufferSize
-
-
Constructor Summary
Constructors Constructor Description NIOTcpPacketTransport(String id, NIOTcpMultiplexer multiplexer, URI transportURI, Settings settings)ConstructorNIOTcpPacketTransport(String id, NIOTcpMultiplexer multiplexer, SocketChannel socketChannel, Settings settings)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanappendOutgoingData()Append some outgoing data to the output buffervoidclose()Stop and close the transport layerprotected voidcloseTransport(boolean linkFailed)ByteBuffergetInputBuffer()Get this client's input bufferByteBuffergetOutputBuffer()Get this client's output bufferSocketAddressgetRemotePeer()Get the remote peer addressSocketChannelgetSocketChannel()Get the associated socket channelbooleanhandleIncomingData()Process incoming data available in the input bufferbooleanhasWriteInterest()Test if this client has things to sendsbooleanneedsThrottling()Test if send operation should be throttled down to avoid send queue overflowvoidonSocketChannelClosed()Called if the multiplexer closes the socket channel after a network errorvoidsend(AbstractPacket packet)Send a packet on this transportvoidstart()Start the transport layer-
Methods inherited from class net.timewalker.ffmq4.transport.tcp.AbstractTcpPacketTransport
getRemotePeerID
-
Methods inherited from class net.timewalker.ffmq4.transport.AbstractPacketTransport
getId, isClosed, setListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.timewalker.ffmq4.transport.tcp.nio.NIOClientSocketHandler
getId
-
-
-
-
Constructor Detail
-
NIOTcpPacketTransport
public NIOTcpPacketTransport(String id, NIOTcpMultiplexer multiplexer, URI transportURI, Settings settings) throws PacketTransportException
Constructor- Throws:
PacketTransportException
-
NIOTcpPacketTransport
public NIOTcpPacketTransport(String id, NIOTcpMultiplexer multiplexer, SocketChannel socketChannel, Settings settings)
Constructor
-
-
Method Detail
-
getRemotePeer
public SocketAddress getRemotePeer()
Description copied from class:AbstractTcpPacketTransportGet the remote peer address- Specified by:
getRemotePeerin classAbstractTcpPacketTransport- Returns:
- the remote peer address (may return null if not available)
-
getInputBuffer
public ByteBuffer getInputBuffer()
Description copied from interface:NIOClientSocketHandlerGet this client's input buffer- Specified by:
getInputBufferin interfaceNIOClientSocketHandler- Returns:
- this client's input buffer
-
getOutputBuffer
public ByteBuffer getOutputBuffer()
Description copied from interface:NIOClientSocketHandlerGet this client's output buffer- Specified by:
getOutputBufferin interfaceNIOClientSocketHandler- Returns:
- this client's output buffer
-
getSocketChannel
public SocketChannel getSocketChannel()
Description copied from interface:NIOClientSocketHandlerGet the associated socket channel- Specified by:
getSocketChannelin interfaceNIOClientSocketHandler- Returns:
- the associated socket channel
-
handleIncomingData
public boolean handleIncomingData()
Description copied from interface:NIOClientSocketHandlerProcess incoming data available in the input buffer- Specified by:
handleIncomingDatain interfaceNIOClientSocketHandler- Returns:
- false on error causing the multiplexer to drop the client handler
-
appendOutgoingData
public boolean appendOutgoingData()
Description copied from interface:NIOClientSocketHandlerAppend some outgoing data to the output buffer- Specified by:
appendOutgoingDatain interfaceNIOClientSocketHandler- Returns:
- false on error causing the multiplexer to drop the client handler
-
hasWriteInterest
public boolean hasWriteInterest()
Description copied from interface:NIOClientSocketHandlerTest if this client has things to sends- Specified by:
hasWriteInterestin interfaceNIOClientSocketHandler- Returns:
- true if this client has things to sends
-
send
public void send(AbstractPacket packet) throws PacketTransportException
Description copied from interface:PacketTransportSend a packet on this transport- Specified by:
sendin interfacePacketTransport- Throws:
PacketTransportException
-
needsThrottling
public boolean needsThrottling()
Description copied from interface:PacketTransportTest if send operation should be throttled down to avoid send queue overflow- Specified by:
needsThrottlingin interfacePacketTransport
-
start
public void start() throws PacketTransportExceptionDescription copied from interface:PacketTransportStart the transport layer- Specified by:
startin interfacePacketTransport- Throws:
PacketTransportException
-
closeTransport
protected void closeTransport(boolean linkFailed)
-
onSocketChannelClosed
public void onSocketChannelClosed()
Description copied from interface:NIOClientSocketHandlerCalled if the multiplexer closes the socket channel after a network error- Specified by:
onSocketChannelClosedin interfaceNIOClientSocketHandler
-
close
public void close()
Description copied from interface:PacketTransportStop and close the transport layer- Specified by:
closein interfacePacketTransport
-
-