I have two controllers, namely ControllerA and ControllerB. In ControllerA I have an object (a HashMap) which maps principal names for connected users to their respective usernames:
@Controller
public class ControllerA {
HashMap<String, String> principalToUsername = new HashMap<>();
...
}
I would like to be able to access this object from ControllerB, which is another websocket controller:
@Controller
public class ControllerB {
private String getUsername(String principalName) {
// I want to access usernames here
}
}
How can I do this? All posts I've read speak about MVC controllers, in which I can use @SessionVariable or flash attributes. But how do I accomplish the same with WebSocket controllers?