Package org.nustaq.kontraktor.asyncio
Class QueuingAsyncSocketConnection
java.lang.Object
org.nustaq.kontraktor.asyncio.AsyncSocketConnection
org.nustaq.kontraktor.asyncio.QueuingAsyncSocketConnection
- Direct Known Subclasses:
ObjectAsyncSocketConnection
public abstract class QueuingAsyncSocketConnection extends AsyncSocketConnection
Created by moelrue on 5/5/15.
A server socket connection which buffers incoming/outgoing data in a binary queue so
an application can easily parse and process data async in chunks without having
to maintain complex state machines.
-
Field Summary
Fields Modifier and Type Field Description static longMAX_Q_SIZE_BYTESprotected org.nustaq.offheap.BinaryQueuereadQueueprotected org.nustaq.offheap.bytez.niobuffers.ByteBufferBasicBytezwrapperprotected org.nustaq.offheap.BinaryQueuewriteQueueFields inherited from class org.nustaq.kontraktor.asyncio.AsyncSocketConnection
chan, isClosed, key, myActor, readBuf, theExecutingThread, writePromise, writingBuffer -
Constructor Summary
Constructors Constructor Description QueuingAsyncSocketConnection(java.nio.channels.SelectionKey key, java.nio.channels.SocketChannel chan) -
Method Summary
Modifier and Type Method Description protected voidcheckQSize()voiddataReceived(java.nio.ByteBuffer buf)protected abstract voiddataReceived(org.nustaq.offheap.BinaryQueue queue)voidtryFlush()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int val)voidwrite(java.nio.ByteBuffer buf)Methods inherited from class org.nustaq.kontraktor.asyncio.AsyncSocketConnection
canWrite, checkThread, close, closed, directWrite, isClosed
-
Field Details
-
MAX_Q_SIZE_BYTES
public static long MAX_Q_SIZE_BYTES -
readQueue
protected org.nustaq.offheap.BinaryQueue readQueue -
writeQueue
protected org.nustaq.offheap.BinaryQueue writeQueue -
wrapper
protected org.nustaq.offheap.bytez.niobuffers.ByteBufferBasicBytez wrapper
-
-
Constructor Details
-
QueuingAsyncSocketConnection
public QueuingAsyncSocketConnection(java.nio.channels.SelectionKey key, java.nio.channels.SocketChannel chan)
-
-
Method Details
-
checkQSize
protected void checkQSize() -
write
public void write(java.nio.ByteBuffer buf) -
write
public void write(byte[] b) -
write
public void write(byte[] b, int off, int len) -
write
public void write(int val) -
tryFlush
public void tryFlush() -
dataReceived
public void dataReceived(java.nio.ByteBuffer buf)- Specified by:
dataReceivedin classAsyncSocketConnection
-
dataReceived
protected abstract void dataReceived(org.nustaq.offheap.BinaryQueue queue)
-