Package server
Class UserChatMap
java.lang.Object
server.UserChatMap
Supporting bi directional data structure for storing (user, chat) tuples.
Users are unique while chats are not.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the chat that a user is active inGets all users that are active in a chatvoidAdd or change a (user, chat) tuple.voidRemoves a user from the map.
-
Constructor Details
-
UserChatMap
public UserChatMap()Constructor added to prevent javadoc warning
-
-
Method Details
-
put
Add or change a (user, chat) tuple.- Parameters:
user- is the userchat- is the chat that the user is active in
-
getChat
Gets the chat that a user is active in- Parameters:
user- username- Returns:
- chatname
-
getUsers
Gets all users that are active in a chat- Parameters:
chat- chatname- Returns:
- Set of usernames
-
remove
Removes a user from the map. Should be used when a user disconnects.- Parameters:
user- username
-