Class JettyWebsocketRouter
java.lang.Object
io.fluxzero.testserver.websocket.JettyWebsocketRouter
Embedded Jetty router for the test server's WebSocket endpoints and health check.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRoute(String path, Function<ServerWebsocketSession, WebsocketEndpoint> endpointSupplier) Registers a WebSocket route.org.eclipse.jetty.server.Serverstart(int port) Starts Jetty on the given port.
-
Constructor Details
-
JettyWebsocketRouter
public JettyWebsocketRouter()
-
-
Method Details
-
addRoute
public JettyWebsocketRouter addRoute(String path, Function<ServerWebsocketSession, WebsocketEndpoint> endpointSupplier) Registers a WebSocket route.- Parameters:
path- route path, with or without leading/trailing slashendpointSupplier- creates the Fluxzero endpoint for each accepted session- Returns:
- this router
-
start
Starts Jetty on the given port.The server does not register Jetty's JVM shutdown hook. When the returned server is stopped, the router shuts down any endpoints it created.
- Returns:
- the started Jetty server, owned by the caller
- Throws:
Exception
-