Class QuicConnection
- All Implemented Interfaces:
Closeable, AutoCloseable, Connection, Invocable
- Direct Known Subclasses:
ClientQuicConnection, ServerQuicConnection
A Connection implementation that receives and sends datagram packets via its associated DatagramChannelEndPoint.
The received bytes are peeked to obtain the QUIC connection ID; each QUIC connection ID has an associated
QuicSession, and the received bytes are then passed to the QuicSession for processing.
On the receive side, one QuicConnection fans-out to multiple QuicSessions.
On the send side, many QuicSessions fan-in to one QuicConnection.
-
Nested Class Summary
Nested classes/interfaces inherited from interface Connection
Connection.Listener, Connection.UpgradeFrom, Connection.UpgradeToNested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task -
Field Summary
Fields inherited from interface Invocable
__nonBlocking, NOOP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedQuicConnection(Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, EndPoint endPoint) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(EventListener listener) Adds a listener of connection events.voidclose()Performs a logical close of this connection.protected abstract QuicSessioncreateSession(SocketAddress remoteAddress, ByteBuffer cipherBuffer) voidUtility method to be called to register read interest.abstract InetSocketAddressintbooleanbooleanvoidCallback method invoked when this connection is closed.protected voidvoidCallback method invoked when the endpoint is ready to be read.abstract booleanonIdleExpired(TimeoutException timeoutException) Callback method invoked upon an idle timeout event.voidonOpen()Callback method invoked when this connection is opened.voidoutwardClose(QuicSession session, Throwable failure) protected Runnableprocess(QuicSession session, SocketAddress remoteAddress, ByteBuffer cipherBuffer) voidremoveEventListener(EventListener listener) Removes a listener of connection events.voidsetOutputBufferSize(int outputBufferSize) voidsetUseInputDirectByteBuffers(boolean useInputDirectByteBuffers) voidsetUseOutputDirectByteBuffers(boolean useOutputDirectByteBuffers) voidwrite(Callback callback, SocketAddress remoteAddress, ByteBuffer... buffers) Methods inherited from class AbstractConnection
failedCallback, getBytesIn, getBytesOut, getCreatedTimeStamp, getEndPoint, getExecutor, getInputBufferSize, getInvocationType, getMessagesIn, getMessagesOut, isFillInterested, onFillInterestedFailed, onReadTimeout, setInputBufferSize, toConnectionString, toString, tryFillInterested
-
Constructor Details
-
QuicConnection
protected QuicConnection(Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, EndPoint endPoint)
-
-
Method Details
-
getScheduler
-
getByteBufferPool
-
getOutputBufferSize
public int getOutputBufferSize() -
setOutputBufferSize
public void setOutputBufferSize(int outputBufferSize) -
isUseInputDirectByteBuffers
public boolean isUseInputDirectByteBuffers() -
setUseInputDirectByteBuffers
public void setUseInputDirectByteBuffers(boolean useInputDirectByteBuffers) -
isUseOutputDirectByteBuffers
public boolean isUseOutputDirectByteBuffers() -
setUseOutputDirectByteBuffers
public void setUseOutputDirectByteBuffers(boolean useOutputDirectByteBuffers) -
getQuicSessions
-
addEventListener
Description copied from interface:ConnectionAdds a listener of connection events.
- Specified by:
addEventListenerin interfaceConnection- Overrides:
addEventListenerin classAbstractConnection- Parameters:
listener- the listener to add
-
removeEventListener
Description copied from interface:ConnectionRemoves a listener of connection events.
- Specified by:
removeEventListenerin interfaceConnection- Overrides:
removeEventListenerin classAbstractConnection- Parameters:
listener- the listener to remove
-
onOpen
public void onOpen()Description copied from interface:ConnectionCallback method invoked when this connection is opened.
Creators of the connection implementation are responsible for calling this method.
- Specified by:
onOpenin interfaceConnection- Overrides:
onOpenin classAbstractConnection
-
onClose
Description copied from interface:ConnectionCallback method invoked when this connection is closed.
Creators of the connection implementation are responsible for calling this method.
- Specified by:
onClosein interfaceConnection- Overrides:
onClosein classAbstractConnection- Parameters:
cause- The cause of the close or null for a normal close
-
onFillable
public void onFillable()Description copied from class:AbstractConnectionCallback method invoked when the endpoint is ready to be read.
- Specified by:
onFillablein classAbstractConnection- See Also:
-
fillInterested
public void fillInterested()Description copied from class:AbstractConnectionUtility method to be called to register read interest.
After a call to this method,
AbstractConnection.onFillable()orAbstractConnection.onFillInterestedFailed(Throwable)will be called back as appropriate.- Overrides:
fillInterestedin classAbstractConnection- See Also:
-
onIdleExpired
Description copied from interface:ConnectionCallback method invoked upon an idle timeout event.
Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed.
When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event.
- Specified by:
onIdleExpiredin interfaceConnection- Overrides:
onIdleExpiredin classAbstractConnection- Returns:
- true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
-
close
public void close()Description copied from interface:ConnectionPerforms a logical close of this connection.
For simple connections, this may just mean to delegate the close to the associated
EndPointbut, for example, SSL connections should write the SSL close message before closing the associatedEndPoint.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceConnection- Overrides:
closein classAbstractConnection
-
outwardClose
-
createSession
protected abstract QuicSession createSession(SocketAddress remoteAddress, ByteBuffer cipherBuffer) throws IOException - Throws:
IOException
-
getLocalInetSocketAddress
-
write
-
process
protected Runnable process(QuicSession session, SocketAddress remoteAddress, ByteBuffer cipherBuffer) -
onFailure
-