Package client

Interface ChatModelListener

All Known Implementing Classes:
ChatView

public interface ChatModelListener
ChatModelListener - Observer interface for ChatModel changes. Allows the View to be notified of model updates without the Model knowing about Swing.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Triggered when a specific chat room has been selected by the user.
    void
    onChatsLoaded(ArrayList<String> chats, String ActiveChat)
    Triggered when the list of available chat rooms has been fetched from the server.
    void
    Triggered when the local user adds a message to a chat.
    void
    Triggered when a new message is received from the server.
    void
    updateUserList(String chatName, String[] activeUsers, ArrayList<String> inChatUsers)
    Triggered when there is an update to the users present in a specific chat.
  • Method Details

    • onMessageAdded

      void onMessageAdded(Chat chat)
      Triggered when the local user adds a message to a chat.
      Parameters:
      chat - The Chat object in which the message is being added.
    • onChatsLoaded

      void onChatsLoaded(ArrayList<String> chats, String ActiveChat)
      Triggered when the list of available chat rooms has been fetched from the server. Use this to rebuild the sidebar or chat navigation list.
      Parameters:
      chats - An ArrayList of strings representing the names of available chat rooms.
      ActiveChat - The name of the currently selected chat room.
    • onChatSelected

      void onChatSelected(Chat chat)
      Triggered when a specific chat room has been selected by the user. This notifies the view to switch the display to the messages of the chosen chat.
      Parameters:
      chat - The Chat object representing the newly selected room.
    • onMessageReceived

      void onMessageReceived(Message message)
      Triggered when a new message is received from the server. This allows the UI to append a single message to the current view without refreshing the whole chat.
      Parameters:
      message - The incoming Message object.
    • updateUserList

      void updateUserList(String chatName, String[] activeUsers, ArrayList<String> inChatUsers)
      Triggered when there is an update to the users present in a specific chat. This updates both the globally active users and those specifically in the room.
      Parameters:
      chatName - The name of the chat room being updated.
      activeUsers - A list of all users currently online on the server.
      inChatUsers - A list of users specifically joined to the named chat room.