@Internal public final class WebSocketSessionEngine extends Object
Combines frame decoding (inbound), frame encoding with queue management
(outbound), close-handshake logic, and the application-facing WebSocket
facade. All transport-specific I/O is delegated to a WebSocketTransport.
Thread model: onData(ByteBuffer) and onOutputReady() must be
called from the I/O thread. The WebSocket facade methods may be called
from any thread; they use a write lock for queue access.
| Constructor and Description |
|---|
WebSocketSessionEngine(WebSocketTransport transport,
WebSocketListener listener,
WebSocketClientConfig cfg,
ExtensionChain chain,
ScheduledExecutorService closeTimer) |
| Modifier and Type | Method and Description |
|---|---|
int |
availableForOutput()
Returns queued byte count for the H2
available() callback. |
WebSocket |
facade()
Returns the application-facing WebSocket.
|
void |
onData(ByteBuffer src)
Push received bytes into the engine for frame decoding and dispatch.
|
void |
onDisconnected()
Called when the underlying transport disconnects or the stream ends
without a proper close handshake.
|
void |
onError(Exception cause)
Called when the transport signals an error.
|
boolean |
onOutputReady()
Drain the outbound queues into the transport.
|
public WebSocketSessionEngine(WebSocketTransport transport, WebSocketListener listener, WebSocketClientConfig cfg, ExtensionChain chain, ScheduledExecutorService closeTimer)
transport - the underlying I/O channellistener - application callbackcfg - client configurationchain - negotiated extension chain (may be null)closeTimer - scheduled executor for H2 close timeout; null for H1
(H1 uses WebSocketTransport.setTimeout(org.apache.hc.core5.util.Timeout) instead)public WebSocket facade()
public void onData(ByteBuffer src)
public void onDisconnected()
public void onError(Exception cause)
public boolean onOutputReady()
true if more output is pending (caller should keep
the write interest), false if queues are emptypublic int availableForOutput()
available() callback.Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.