Class GrpcFrames.Decoder

java.lang.Object
com.codename1.backend.grpc.GrpcFrames.Decoder
Enclosing class:
GrpcFrames

public static final class GrpcFrames.Decoder extends Object
Reassembles messages from bytes as they arrive. Not thread safe; one per stream direction.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Decoder(int maxMessage, boolean gzipAccepted)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<byte[]>
    feed(byte[] data, int offset, int length)
    Feeds bytes and returns every message they completed, in order.
    boolean
    Whether the stream ended cleanly between messages.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Decoder

      public Decoder(int maxMessage, boolean gzipAccepted)
      Parameters:
      maxMessage - the largest message accepted, compressed or not
      gzipAccepted - whether the peer declared grpc-encoding: gzip
  • Method Details

    • feed

      public List<byte[]> feed(byte[] data, int offset, int length)
      Feeds bytes and returns every message they completed, in order.
      Parameters:
      data - the bytes
      offset - where they start
      length - how many
      Returns:
      the completed messages, possibly empty, never null
      Throws:
      GrpcException - on a malformed or oversized message
    • isIdle

      public boolean isIdle()
      Whether the stream ended cleanly between messages. A stream that ends halfway through one lost data, and the caller must say so.
      Returns:
      true when no partial message is buffered