java.lang.Object
io.helidon.webserver.websocket.WsConnection
- All Implemented Interfaces:
ServerConnection
,WsSession
WebSocket connection, server side session implementation.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(boolean interrupt) Close a connection.Close session.static WsConnection
create
(ConnectionContext ctx, HttpPrologue prologue, Headers upgradeHeaders, String wsKey, WsRoute wsRoute) Create a new connection using a route.static WsConnection
create
(ConnectionContext ctx, HttpPrologue prologue, Headers upgradeHeaders, String wsKey, WsListener wsListener) Create a new connection using a listener.void
Start handling the connection.idleTime()
How long is this connection idle.ping
(BufferData bufferData) Send ping.pong
(BufferData bufferData) Send pong.send
(BufferData bufferData, boolean last) Send binary fragment.Send text fragment.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:ServerConnection
Start handling the connection. Data is provided throughServerConnectionSelector.connection(io.helidon.webserver.ConnectionContext)
.- Specified by:
handle
in interfaceServerConnection
- Parameters:
requestSemaphore
- semaphore that is responsible for maximal concurrent request limit, the connection implementation is responsible for acquiring a permit from the semaphore for the duration of a request, and releasing it when the request ends; please be very careful, as this may lead to complete stop of the server if incorrectly implemented
-
send
Description copied from interface:WsSession
Send text fragment. -
send
Description copied from interface:WsSession
Send binary fragment. -
ping
Description copied from interface:WsSession
Send ping. -
pong
Description copied from interface:WsSession
Send pong. -
close
Description copied from interface:WsSession
Close session.- Specified by:
close
in interfaceWsSession
- Parameters:
code
- close code, may be one ofWsCloseCodes
reason
- reason description- Returns:
- this instance
-
terminate
Description copied from interface:WsSession
Terminate session. Sends a close and closes the connection. -
subProtocol
Description copied from interface:WsSession
The WebSocket sub-protocol negotiated for this session.- Specified by:
subProtocol
in interfaceWsSession
- Returns:
- sub-protocol negotiated, if any
-
idleTime
Description copied from interface:ServerConnection
How long is this connection idle. This is a duration from the last request to now.- Specified by:
idleTime
in interfaceServerConnection
- Returns:
- idle duration
-
close
public void close(boolean interrupt) Description copied from interface:ServerConnection
Close a connection. This may be called during shutdown of the server, or when idle timeout is reached.- Specified by:
close
in interfaceServerConnection
- Parameters:
interrupt
- whether to interrupt in progress requests (always interrupts idle requests waiting for initial request data)
-