VAVR collections are "immutable".
So, if I have static variable, for example, holding all the WebSocket sessions, how would I use VAVR so that the collection is thread safe?
For example:
@ServerEndpoint("/actions")
public class DeviceWebSocketServer {
private static Set<Session> sessions = //???; // how should I initialize this?
@OnOpen
public void open(Session session) {
sessions = sessions.add(session); // is this OK???
}
@OnClose
public void close(Session session) {
sessions = sessions.remove(session); // is this OK??
}
}