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.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:ServerConnectionStart handling the connection. Data is provided throughServerConnectionSelector.connection(io.helidon.webserver.ConnectionContext).- Specified by:
handlein 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:WsSessionSend text fragment. -
send
Description copied from interface:WsSessionSend binary fragment. -
ping
Description copied from interface:WsSessionSend ping. -
pong
Description copied from interface:WsSessionSend pong. -
close
Description copied from interface:WsSessionClose session.- Specified by:
closein interfaceWsSession- Parameters:
code- close code, may be one ofWsCloseCodesreason- reason description- Returns:
- this instance
-
terminate
Description copied from interface:WsSessionTerminate session. Sends a close and closes the connection. -
subProtocol
Description copied from interface:WsSessionThe WebSocket sub-protocol negotiated for this session.- Specified by:
subProtocolin interfaceWsSession- Returns:
- sub-protocol negotiated, if any
-
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)
-