Interface MessageBuffer

All Known Subinterfaces:
MessageBuffer.Wrapped<T>

public interface MessageBuffer
A buffer for messages that can be sent over the network.
Since:
2.9.2
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Represents a buffer that wraps an internal buffer type.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the length of the buffer.
    <T> T
    read(DataType<T> type)
    Reads a value from the buffer using the provided DataType.
    byte[]
    Serializes the buffer to a byte array.
    <T> void
    write(DataType<T> type, T value)
    Writes a value to the buffer using the provided DataType.
  • Method Details

    • read

      <T> T read(DataType<T> type)
      Reads a value from the buffer using the provided DataType.
      Type Parameters:
      T - the type of message to read
      Parameters:
      type - the type of message to read
      Returns:
      the read message
    • write

      <T> void write(DataType<T> type, T value)
      Writes a value to the buffer using the provided DataType.
      Type Parameters:
      T - the type of message to write
      Parameters:
      type - the type of message to write
      value - the value to write
    • serialize

      byte[] serialize()
      Serializes the buffer to a byte array.
      Returns:
      the serialized byte array
    • length

      int length()
      Gets the length of the buffer.
      Returns:
      the length of the buffer