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 TypeMethodDescriptionvoidonChatSelected(Chat chat) Triggered when a specific chat room has been selected by the user.voidonChatsLoaded(ArrayList<String> chats, String ActiveChat) Triggered when the list of available chat rooms has been fetched from the server.voidonMessageAdded(Chat chat) Triggered when the local user adds a message to a chat.voidonMessageReceived(Message message) Triggered when a new message is received from the server.voidupdateUserList(String chatName, String[] activeUsers, ArrayList<String> inChatUsers) Triggered when there is an update to the users present in a specific chat.
-
Method Details
-
onMessageAdded
Triggered when the local user adds a message to a chat.- Parameters:
chat- The Chat object in which the message is being added.
-
onChatsLoaded
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
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
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
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.
-