Class WebChannelParser

java.lang.Object
com.codename1.cloud.firebase.WebChannelParser

public final class WebChannelParser extends Object

Splits a WebChannel response body into its framed arrays.

The Firestore Listen channel answers with frames of the form <length>\n<json array>. The array holds [arrayId, payload] pairs. The parser is incremental: text can arrive in any split and is buffered until a frame is complete. The length counts characters of the decoded text, as the JavaScript client reads it.

  • Constructor Details

    • WebChannelParser

      public WebChannelParser()
  • Method Details

    • feed

      public List<WebChannelParser.Entry> feed(String text)

      Adds text and returns every entry of the frames it completed.

      Parameters
      • text: the next part of the response body
      Returns

      the completed entries in order, possibly empty

      Throws
      • IllegalStateException: when the body is not WebChannel framing
    • getLastArrayId

      public long getLastArrayId()
      Returns

      the highest array ID seen, or -1

    • resetBuffer

      public void resetBuffer()
      Discards buffered text, for a new response.