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 ClientWsConnectioncreate(ClientConnection clientConnection, WsListener listener) Create a new connection without a sub-protocol.static ClientWsConnectioncreate(ClientConnection clientConnection, WsListener listener, String subProtocol) Create a new connection.ping(BufferData bufferData) Send ping.pong(BufferData bufferData) Send pong.voidrun()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: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
-