Class ExitCommand

java.lang.Object
com.example.common.command.BaseCommand
com.example.common.command.ExitCommand
All Implemented Interfaces:
Command

public class ExitCommand extends BaseCommand
Class for user command - EXIT
  • Constructor Details

    • ExitCommand

      public ExitCommand(MessageSender messageSender, ChatInterface chatInterface)
      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

      public Status execute(BodyMessage bodyMessage) throws IOException
      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.