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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection.voidonText(WebSocket webSocket, CharSequence data, boolean last) voidSends the given message to the Vite server.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.net.http.WebSocket.Listener
onBinary, onError, onPing, onPong
-
Constructor Details
-
ViteWebsocketConnection
public ViteWebsocketConnection(int port, String path, 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 onpath- the path Vite is usingsubProtocol- 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:
onOpenin interfaceWebSocket.Listener
-
onClose
- Specified by:
onClosein interfaceWebSocket.Listener
-
onText
- Specified by:
onTextin 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
-