Interface PartialReadMessage

All Superinterfaces:
AutoCloseable, io.netty.util.ReferenceCounted, RemoteMessage
All Known Implementing Classes:
ArmedProtocolMessage, UnarmedProtocolMessage

public interface PartialReadMessage extends RemoteMessage, io.netty.util.ReferenceCounted, AutoCloseable
Describes a message whose content has been read partially. This is the case for encrypted messages, chunks or messages that do not need to be read completely.
See Also:
  • Method Details

    • getBytes

      io.netty.buffer.ByteBuf getBytes()
      Returns the remainder of unread bytes of this message.
      Returns:
      the remainder of unread bytes of this message
    • close

      void close()
      Calls ReferenceCounted.release().
      Specified by:
      close in interface AutoCloseable
    • of

      static PartialReadMessage of(PublicHeader publicHeader, io.netty.buffer.ByteBuf bytes)
      Creates a PartialReadMessage from publicHeader and bytes.

      ReferenceCounted.release() ownership of bytes is transferred to this PartialReadMessage.

      Modifying the content of bytes or the returned message's buffer affects each other's content while they maintain separate indexes and marks.

      Parameters:
      publicHeader - message's public header
      bytes - message's remainder as bytes (may be armed). ReferenceCounted.release() ownership is transferred to this PartialReadMessage.
      Returns:
      an PartialReadMessage object
      Throws:
      NullPointerException - if publicHeader.getNonce(), publicHeader.getSender(), publicHeader.getProofOfWork(), or publicHeader.getRecipient() is null
      IllegalArgumentException - if publicHeader.getSender() or publicHeader.getRecipient() has wrong key size, or publicHeader.getAgreementId() is neither null nor a valid SHA256 hash
    • of

      static PartialReadMessage of(io.netty.buffer.ByteBuf bytes) throws InvalidMessageFormatException
      Creates a PartialReadMessage from bytes. First, this method checks if bytes starts with RemoteMessage.MAGIC_NUMBER, then reads the message's public header:

      ReferenceCounted.release() ownership of bytes is transferred to this PartialReadMessage.

      Modifying the content of bytes or the returned message's buffer affects each other's content while they maintain separate indexes and marks.

      Parameters:
      bytes - message's bytes (may be partially armed). ReferenceCounted.release() ownership is transferred to this PartialReadMessage.
      Returns:
      an PartialReadMessage object
      Throws:
      NullPointerException - if publicHeader.getNonce(), publicHeader.getSender(), publicHeader.getProofOfWork(), or publicHeader.getRecipient() is null
      IllegalArgumentException - if publicHeader.getSender() or publicHeader.getRecipient() has wrong key size, or publicHeader.getAgreementId() is neither null nor a valid SHA256 hash
      InvalidMessageFormatException - if magic number or public header is missing