Package io.helidon.webclient.websocket
Class ClientWsConnection
java.lang.Object
io.helidon.webclient.websocket.ClientWsConnection
Client WebSocket connection. This connection handles a single WebSocket interaction, using
WsListener
to handle connection events.-
Method Summary
Modifier and TypeMethodDescriptionClose session.static ClientWsConnection
create
(ClientConnection clientConnection, WsListener listener) Create a new connection without a sub-protocol.static ClientWsConnection
create
(ClientConnection clientConnection, WsListener listener, String subProtocol) Create a new connection.ping
(BufferData bufferData) Send ping.pong
(BufferData bufferData) Send pong.void
run()
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 ClientWsConnection create(ClientConnection clientConnection, WsListener listener, String subProtocol) Create a new connection. The connection needs to run on ana executor service (it implementsRunnable
) so it does not block the current thread.- Parameters:
clientConnection
- connection to use for this WS connectionlistener
- WebSocket listener to handle events on this connectionsubProtocol
- chosen sub-protocol of this connection (negotiated during upgrade from HTTP/1)- Returns:
- a new WebSocket connection
-
create
Create a new connection without a sub-protocol.- Parameters:
clientConnection
- connection to work onlistener
- WebSocket listener to handle events on this connection- Returns:
- a new WebSocket connection
-
run
public void run() -
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
-