I am trying to loop through a hashmap which contains Sessions and IDs. Multiple sessions may have the same ID. On each method call, I need to iterate through the hashmap and find which sessions are listed against a given ID.
class contains:
private static Map<Session, String> peers = new HashMap<Session, String> ();
Method contains:
for (Map.Entry<Session, String> entry : peers.entrySet()) {
if(entry.getValue() == clientId){
Session peer = entry.getKey();
peer.getBasicRemote().sendObject(figure);
}
}
But the problem is it runs only one time. Even I tried to get the size of hashmap and it given the exactly amount what I have.
if(entry.getValue().equals(clientId)){