Package io.jmix.flowui.devserver
Class ViteWebsocketConnection
java.lang.Object
io.jmix.flowui.devserver.ViteWebsocketConnection
- All Implemented Interfaces:
WebSocket.Listener
Communicates with a Vite server through a websocket connection.
-
Constructor Summary
ConstructorDescriptionViteWebsocketConnection
(int port, String subProtocol, Consumer<String> onMessage, Runnable onClose) Established a connection with a Vite server running on the given port, using the given sub protocol. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the connection.void
onText
(WebSocket webSocket, CharSequence data, boolean last) void
Sends the given message to the Vite server.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.net.http.WebSocket.Listener
onBinary, onError, onPing, onPong
-
Constructor Details
-
ViteWebsocketConnection
public ViteWebsocketConnection(int port, String subProtocol, Consumer<String> onMessage, Runnable onClose) throws InterruptedException, ExecutionException Established a connection with a Vite server running on the given port, using the given sub protocol.- Parameters:
port
- the port Vite is running onsubProtocol
- the sub protocol to useonMessage
- a callback to invoke when a message arrives.onClose
- a callback to invoke if the connection to Vite is closed- Throws:
InterruptedException
- if there is a problem with the connectionExecutionException
- if there is a problem with the connection
-
-
Method Details
-
onOpen
- Specified by:
onOpen
in interfaceWebSocket.Listener
-
onClose
- Specified by:
onClose
in interfaceWebSocket.Listener
-
onText
- Specified by:
onText
in interfaceWebSocket.Listener
-
send
Sends the given message to the Vite server.- Parameters:
message
- the message to send- Throws:
InterruptedException
- if there is a problem with the connectionExecutionException
- if there is a problem with the connection
-
close
Closes the connection.- Throws:
ExecutionException
- if there is a problem with the connectionInterruptedException
- if there is a problem with the connection
-