Package io.helidon.nima.websocket.client
Class ClientWsConnection
java.lang.Object
io.helidon.nima.websocket.client.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(WsListener listener, HelidonSocket helidonSocket, DataReader reader, DataWriter writer, Optional<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(WsListener listener, HelidonSocket helidonSocket, DataReader reader, DataWriter writer, Optional<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:
listener- WebSocket listener to handle events on this connectionhelidonSocket- Helidon Socket to obtain information about peerreader- used to read data from remote serverwriter- use to write data to remote serversubProtocol- chosen sub-protocol of this connection (negotiated during upgrade from HTTP/1)- 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
-