Package com.example.common.command
Class MessageCommand
java.lang.Object
com.example.common.command.BaseCommand
com.example.common.command.MessageCommand
- All Implemented Interfaces:
Command
The MessageCommand class represents a command that handles user messages in the chat application.
-
Field Summary
Fields inherited from class com.example.common.command.BaseCommand
chatInterface, description, messageSender, name
-
Constructor Summary
ConstructorsConstructorDescriptionMessageCommand
(MessageSender messageSender, ChatInterface chatInterface, CommandsInterface commands) -
Method Summary
Modifier and TypeMethodDescriptionexecute
(BodyMessage bodyMessage) Executes the MessageCommand by processing the body message received from a user.Methods inherited from class com.example.common.command.BaseCommand
getDescription, getName
-
Constructor Details
-
MessageCommand
public MessageCommand(MessageSender messageSender, ChatInterface chatInterface, CommandsInterface commands)
-
-
Method Details
-
execute
Executes the MessageCommand by processing the body message received from a user. If the message corresponds to a command, it executes the command; otherwise, it sends the message to the chat.- Parameters:
bodyMessage
- The BodyMessage containing the user's message details.- Returns:
- The execution status of the command (SUCCESS or ERROR).
- Throws:
IOException
- if an I/O error occurs during message sending.
-