Package com.example.server.handler
Class RequestHandler
java.lang.Object
com.example.server.handler.RequestHandler
- All Implemented Interfaces:
MessageHandler<TransportConnection>
This class is responsible for handling incoming requests from a TransportConnection.
It receives a message from the connection, deserializes it to a BodyMessage object,
and executes the command specified in the BodyMessage using the CommandsInterface.
It then sends back the status of the command execution to the client.
-
Constructor Summary
ConstructorsConstructorDescriptionRequestHandler
(CommandsInterface commands) Constructor for RequestHandler class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
handle
(TransportConnection transportConnection) Handles the incoming request from the TransportConnection.
-
Constructor Details
-
RequestHandler
Constructor for RequestHandler class.- Parameters:
commands
- The interface containing the available commands to be executed.
-
-
Method Details
-
handle
Handles the incoming request from the TransportConnection. It deserializes the received message, executes the command, and sends back the status of the command execution.- Specified by:
handle
in interfaceMessageHandler<TransportConnection>
- Parameters:
transportConnection
- The connection from which the request is received.
-