Class RequestHandler

java.lang.Object
com.example.server.handler.RequestHandler
All Implemented Interfaces:
MessageHandler<TransportConnection>

public class RequestHandler extends Object implements 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 Details

    • RequestHandler

      public RequestHandler(CommandsInterface commands)
      Constructor for RequestHandler class.
      Parameters:
      commands - The interface containing the available commands to be executed.
  • Method Details

    • handle

      public void handle(TransportConnection transportConnection)
      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 interface MessageHandler<TransportConnection>
      Parameters:
      transportConnection - The connection from which the request is received.