Interface MessageSender<M extends Message>

Type Parameters:
M - Message type
All Known Implementing Classes:
CompressedPacketSender, DebugBufferingPacketSender, SimplePacketSender, SyncMessageSender, TimeTrackingPacketSender, TracingPacketSender

public interface MessageSender<M extends Message>
This interface provides a facility for sending messages to server. The destination, transmission method, etc are determined by the implementation.
  • Method Summary

    Modifier and Type Method Description
    default void send​(byte[] message, int messageLen, byte messageSequence)
    Synchronously send the message to server.
    default void send​(M message)
    Synchronously send the message to server.
    default java.util.concurrent.CompletableFuture<?> send​(M message, java.util.concurrent.CompletableFuture<?> future, java.lang.Runnable callback)
    Asynchronously write a message with a notification being delivered to callback upon completion of write of entire message.
    default void setMaxAllowedPacket​(int maxAllowedPacket)
    Set max allowed packet size.
    default MessageSender<M> undecorate()
    Return the previous PacketSender instance from the decorators chain or the current PacketSender if it is the first entry in a chain.
    default MessageSender<M> undecorateAll()
    Return a PacketSender instance free of decorators.
  • Method Details

    • send

      default void send​(byte[] message, int messageLen, byte messageSequence) throws java.io.IOException
      Synchronously send the message to server.
      Parameters:
      message - byte array containing a message
      messageLen - length of the message
      messageSequence - message sequence index (used in a native protocol)
      Throws:
      java.io.IOException - if an error occurs
    • send

      default void send​(M message)
      Synchronously send the message to server.
      Parameters:
      message - Message instance
    • send

      default java.util.concurrent.CompletableFuture<?> send​(M message, java.util.concurrent.CompletableFuture<?> future, java.lang.Runnable callback)
      Asynchronously write a message with a notification being delivered to callback upon completion of write of entire message.
      Parameters:
      message - message extending Message
      future - a Future returning operation result
      callback - a callback to receive notification of when the message is completely written
      Returns:
      result
    • setMaxAllowedPacket

      default void setMaxAllowedPacket​(int maxAllowedPacket)
      Set max allowed packet size.
      Parameters:
      maxAllowedPacket - max allowed packet size
    • undecorateAll

      default MessageSender<M> undecorateAll()
      Return a PacketSender instance free of decorators.
      Returns:
      MessageSender instance
    • undecorate

      default MessageSender<M> undecorate()
      Return the previous PacketSender instance from the decorators chain or the current PacketSender if it is the first entry in a chain.
      Returns:
      MessageSender instance