Package server

Class UserChatMap

java.lang.Object
server.UserChatMap

public class UserChatMap extends Object
Supporting bi directional data structure for storing (user, chat) tuples. Users are unique while chats are not.
  • Constructor Details

    • UserChatMap

      public UserChatMap()
      Constructor added to prevent javadoc warning
  • Method Details

    • put

      public void put(String user, String chat)
      Add or change a (user, chat) tuple.
      Parameters:
      user - is the user
      chat - is the chat that the user is active in
    • getChat

      public String getChat(String user)
      Gets the chat that a user is active in
      Parameters:
      user - username
      Returns:
      chatname
    • getUsers

      public Set<String> getUsers(String chat)
      Gets all users that are active in a chat
      Parameters:
      chat - chatname
      Returns:
      Set of usernames
    • remove

      public void remove(String user)
      Removes a user from the map. Should be used when a user disconnects.
      Parameters:
      user - username