Package io.helidon.webclient.websocket
Class ClientWsConnection
java.lang.Object
io.helidon.webclient.websocket.ClientWsConnection
- All Implemented Interfaces:
io.helidon.websocket.WsSession,Runnable
Client WebSocket connection. This connection handles a single WebSocket interaction, using
WsListener to handle connection events.-
Method Summary
Modifier and TypeMethodDescriptionio.helidon.websocket.WsSessionCloses WebSocket session.static ClientWsConnectioncreate(io.helidon.webclient.api.ClientConnection clientConnection, io.helidon.websocket.WsListener listener) Create a new connection without a sub-protocol.static ClientWsConnectioncreate(io.helidon.webclient.api.ClientConnection clientConnection, io.helidon.websocket.WsListener listener, String subProtocol) Create a new connection.io.helidon.websocket.WsSessionping(BufferData bufferData) io.helidon.websocket.WsSessionpong(BufferData bufferData) voidrun()io.helidon.websocket.WsSessionsend(BufferData bufferData, boolean last) io.helidon.websocket.WsSessionio.helidon.common.socket.SocketContextio.helidon.websocket.WsSession
-
Method Details
-
create
public static ClientWsConnection create(io.helidon.webclient.api.ClientConnection clientConnection, io.helidon.websocket.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
public static ClientWsConnection create(io.helidon.webclient.api.ClientConnection clientConnection, io.helidon.websocket.WsListener listener) 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
- Specified by:
sendin interfaceio.helidon.websocket.WsSession
-
send
- Specified by:
sendin interfaceio.helidon.websocket.WsSession
-
ping
- Specified by:
pingin interfaceio.helidon.websocket.WsSession
-
pong
- Specified by:
pongin interfaceio.helidon.websocket.WsSession
-
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 interfaceio.helidon.websocket.WsSession- Parameters:
code- close code, may be one ofWsCloseCodesreason- reason description- Returns:
- the session
-
terminate
public io.helidon.websocket.WsSession terminate()- Specified by:
terminatein interfaceio.helidon.websocket.WsSession
-
subProtocol
- Specified by:
subProtocolin interfaceio.helidon.websocket.WsSession
-
socketContext
public io.helidon.common.socket.SocketContext socketContext()- Specified by:
socketContextin interfaceio.helidon.websocket.WsSession
-