Package com.example.common.command
Class ExitCommand
java.lang.Object
com.example.common.command.BaseCommand
com.example.common.command.ExitCommand
- All Implemented Interfaces:
Command
Class for user command - EXIT
-
Field Summary
Fields inherited from class com.example.common.command.BaseCommand
chatInterface, description, messageSender, name
-
Constructor Summary
ConstructorsConstructorDescriptionExitCommand
(MessageSender messageSender, ChatInterface chatInterface) Constructor for the ExitCommand. -
Method Summary
Modifier and TypeMethodDescriptionexecute
(BodyMessage bodyMessage) Executes the ExitCommand by removing the user from the chat and sending a goodbye message to all clients.Methods inherited from class com.example.common.command.BaseCommand
getDescription, getName
-
Constructor Details
-
ExitCommand
Constructor for the ExitCommand.- Parameters:
messageSender
- The MessageSender object for sending messages.chatInterface
- The ChatInterface containing information about clients in the chat.
-
-
Method Details
-
execute
Executes the ExitCommand by removing the user from the chat and sending a goodbye message to all clients.- Parameters:
bodyMessage
- The BodyMessage containing the command details.- Returns:
- The execution status of the command (SUCCESS or ERROR).
- Throws:
IOException
- if an I/O error occurs during message sending.
-