ProblemI am currently working on a JAVA Quarkus backend and I am trying to solve the problem of communtication between users in different so called "rooms" like socket io does it with joining the sockets together (https://socket.io/docs/v3/rooms/.
Basically I want to implement the functionality shown in the image above in Quarkus with WebSockets.
What have I tried?I have found a web-socket solution on the official quarkus website (https://quarkus.io/guides/websockets) but with the provided solution, there is no way to join the websockets together and create these "rooms"/lobbies like in socket io.
The provided code block has a single session for every user:
Map<String, Session> sessions = new ConcurrentHashMap<>(); @OnOpen public void onOpen(Session session, @PathParam("username") String username) { broadcast("User " + username +" joined"); sessions.put(username, session); }
The architecture of the provided quarkus websocket solution looks like this:
My questions
- Is there a way to join a different session together or to create a custom session by PathParams?
- Are there any useful Java libraries providing such lobby/room/join functionality equivalent to socket.io in js?
- Is the provided code somehow changeable to achieve the goal?