Class WsConnection
java.lang.Object
io.helidon.webserver.websocket.WsConnection
- All Implemented Interfaces:
ServerConnection, WsSession
WebSocket connection, server side session implementation.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose(boolean interrupt) Close a connection.Close session.static WsConnectioncreate(ConnectionContext ctx, HttpPrologue prologue, Headers upgradeHeaders, String wsKey, WsRoute wsRoute) Create a new connection using a route.static WsConnectioncreate(ConnectionContext ctx, HttpPrologue prologue, Headers upgradeHeaders, String wsKey, WsListener wsListener) Create a new connection using a listener.voidStart handling the connection.idleTime()How long is this connection idle.ping(BufferData bufferData) Send ping.pong(BufferData bufferData) Send pong.prologue()The HTTP prologue received when opening this session.WebSocket protocol configuration for this session.send(BufferData bufferData, boolean last) Send binary fragment.Send text fragment.The underlying socket context.The WebSocket sub-protocol negotiated for this session.Terminate session.
-
Method Details
-
create
public static WsConnection create(ConnectionContext ctx, HttpPrologue prologue, Headers upgradeHeaders, String wsKey, WsListener wsListener) Create a new connection using a listener.- Parameters:
ctx- server connection contextprologue- prologue of this requestupgradeHeaders- headers forwsKey- ws keywsListener- a ws listener- Returns:
- a new connection
-
create
public static WsConnection create(ConnectionContext ctx, HttpPrologue prologue, Headers upgradeHeaders, String wsKey, WsRoute wsRoute) Create a new connection using a route.- Parameters:
ctx- server connection contextprologue- prologue of this requestupgradeHeaders- headers forwsKey- ws keywsRoute- route to use- Returns:
- a new connection
-
handle
Description copied from interface:ServerConnectionStart handling the connection. Data is provided throughServerConnectionSelector.connection(io.helidon.webserver.ConnectionContext).- Specified by:
handlein interfaceServerConnection- Parameters:
limit- that is responsible for maximal concurrent request limit, the connection implementation is responsible for invoking each request within the limit usingLimitAlgorithm.tryAcquireOutcome(boolean)or the convenience methods onLimitAlgorithm
-
send
-
send
Description copied from interface:WsSessionSend binary fragment. -
ping
Description copied from interface:WsSessionSend ping. -
pong
Description copied from interface:WsSessionSend pong. -
close
-
terminate
-
subProtocol
Description copied from interface:WsSessionThe WebSocket sub-protocol negotiated for this session.- Specified by:
subProtocolin interfaceWsSession- Returns:
- sub-protocol negotiated, if any
-
protocolConfig
Description copied from interface:WsSessionWebSocket protocol configuration for this session.- Specified by:
protocolConfigin interfaceWsSession- Returns:
- WebSocket protocol configuration
-
socketContext
Description copied from interface:WsSessionThe underlying socket context.- Specified by:
socketContextin interfaceWsSession- Returns:
- socket context
-
idleTime
Description copied from interface:ServerConnectionHow long is this connection idle. This is a duration from the last request to now.- Specified by:
idleTimein interfaceServerConnection- Returns:
- idle duration
-
close
public void close(boolean interrupt) Description copied from interface:ServerConnectionClose a connection. This may be called during shutdown of the server, or when idle timeout is reached.- Specified by:
closein interfaceServerConnection- Parameters:
interrupt- whether to interrupt in progress requests (always interrupts idle requests waiting for initial request data)
-
prologue
Description copied from interface:WsSessionThe HTTP prologue received when opening this session. This will only be available on server sessions.
-