java.lang.Object
convex.net.MessageSender
Message sender responsible for moving bytes from a ByteBuffer to a ByteChannel
Must call maybeSendBytes to attempt to flush buffer to channel.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
bufferMessage
(ByteBuffer messageFrame) Buffers a message for sending.boolean
Checks if this sender is ready to send a message.boolean
Try to send bytes on the outbound channel.
-
Field Details
-
log
protected static final org.slf4j.Logger log
-
-
Constructor Details
-
MessageSender
-
-
Method Details
-
bufferMessage
Buffers a message for sending. Message buffer should be flipped, ready for reading- Parameters:
messageFrame
- Source ByteBuffer containing complete message bytes (including length)- Returns:
- True if successfully buffered, false otherwise (insufficient send buffer size)
- Throws:
IOException
- In case of IO Error
-
maybeSendBytes
Try to send bytes on the outbound channel.- Returns:
- True if all bytes have been sent, false otherwise.
- Throws:
IOException
- If IO error occurs
-
canSendMessage
public boolean canSendMessage()Checks if this sender is ready to send a message. Caller should synchronise on this sender in case the state changes concurrently- Returns:
- True if ready, false otherwise
-