Package com.example.client.sender
Class BaseMessageSender
java.lang.Object
com.example.client.sender.BaseMessageSender
- All Implemented Interfaces:
MessageSender
The BaseMessageSender class implements the MessageSender interface for sending messages with a body message payload.
-
Constructor Summary
ConstructorsConstructorDescriptionBaseMessageSender
(TransportFactory transportFactory, String ipServer, int serverPort) Constructs a BaseMessageSender with the specified transport factory, server IP, and port number. -
Method Summary
Modifier and TypeMethodDescriptionboolean
sendMessage
(BodyMessage bodyMessage) Sends a message with the specified BodyMessage payload to the server.
-
Constructor Details
-
BaseMessageSender
Constructs a BaseMessageSender with the specified transport factory, server IP, and port number.- Parameters:
transportFactory
- the TransportFactory for creating connectionsipServer
- the IP address of the serverserverPort
- the port number of the server
-
-
Method Details
-
sendMessage
Sends a message with the specified BodyMessage payload to the server.- Specified by:
sendMessage
in interfaceMessageSender
- 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
-