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 TypeMethodDescriptionCloses WebSocket 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.WebSocket protocol configuration for this session.voidrun()send(BufferData bufferData, boolean last) Send binary fragment.Send text fragment.The underlying socket context.The WebSocket sub-protocol negotiated for this session.Terminate session.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface WsSession
prologueModifier and TypeMethodDescriptiondefault HttpPrologueprologue()The HTTP prologue received when opening this 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
-
send
-
send
Description copied from interface:WsSessionSend binary fragment. -
ping
Description copied from interface:WsSessionSend ping. -
pong
Description copied from interface:WsSessionSend pong. -
close
Closes WebSocket session. Ifcodeis negative, then a CLOSE frame with no code or reason is sent. This can be used to test CLOSE frames with no payload, as required by the spec.- Specified by:
closein interfaceWsSession- Parameters:
code- close code, may be one ofWsCloseCodesreason- reason description- Returns:
- the session
-
terminate
-
subProtocol
Description copied from interface:WsSessionThe WebSocket sub-protocol negotiated for this session.- Specified by:
subProtocolin interfaceWsSession- Returns:
- sub-protocol negotiated, if any
-
protocolConfig
Description copied from interface:WsSessionWebSocket protocol configuration for this session.- Specified by:
protocolConfigin interfaceWsSession- Returns:
- WebSocket protocol configuration
-
socketContext
Description copied from interface:WsSessionThe underlying socket context.- Specified by:
socketContextin interfaceWsSession- Returns:
- socket context
-