I am using quarkus-next websockets (java) and try to understand how websockets work in general.
When I call an rest-endpoint with the function getDances
everything works as expected. When I call this function with a websocket the websocket disconnects after the first line context.request.getHeader("x-schema")
. I tried to comment out this line but also Settings.findAll().firstResult()
does not work.
Service:
@Inject
RoutingContext context;
public List<DanceDTO> getDances() {
String schema = context.request().getHeader( "x-schema" );
Settings settings = Settings.findAll().firstResult();
...
return danceDao.findAllDances();
}
MyWebsocket:
@WebSocket(path = "/beamer/{id}", endpointId = "Dance")
@ApplicationScoped
public class WebsocketEndpoint {
@Inject
WebSocketConnection connection;
@Inject
Danceservice danceService;
@OnOpen()
public List<DanceDTO> onOpen(@PathParam String id) {
return danceService.getDances();
}
@OnClose
public void onClose() {
System.out.println(connection.pathParam("id") + " left the game");
}
}
I would like to send all dances from the database to the client, nothing else.
Thanks for the explanation
Side information, not sure if needed:
Settings.findAll().firstResult();
does work because of Panache.