Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class WebChannelParser
- Object
- WebChannelParser
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.
Nested types
class WebChannelParser.Entry | One [arrayId, payload] entry of a frame. |
Constructors
public WebChannelParser() |
Methods
public List<WebChannelParser.Entry> feed(String text) | Adds text and returns every entry of the frames it completed. |
public long getLastArrayId() | |
public void resetBuffer() | Discards buffered text, for a new response. |
Inherited methods
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
textString- 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.