Class BaseMessageSender

java.lang.Object
com.example.client.sender.BaseMessageSender
All Implemented Interfaces:
MessageSender

public class BaseMessageSender extends Object implements MessageSender
The BaseMessageSender class implements the MessageSender interface for sending messages with a body message payload.
  • Constructor Details

    • BaseMessageSender

      public BaseMessageSender(TransportFactory transportFactory, String ipServer, int serverPort)
      Constructs a BaseMessageSender with the specified transport factory, server IP, and port number.
      Parameters:
      transportFactory - the TransportFactory for creating connections
      ipServer - the IP address of the server
      serverPort - the port number of the server
  • Method Details

    • sendMessage

      public boolean sendMessage(BodyMessage bodyMessage) throws IOException
      Sends a message with the specified BodyMessage payload to the server.
      Specified by:
      sendMessage in interface MessageSender
      Parameters:
      bodyMessage - the BodyMessage payload to send
      Returns:
      true if the message was sent successfully, false otherwise
      Throws:
      IOException - if an error occurs during communication