JsonStreamDecoder
class JsonStreamDecoder (View source)
Constants
ESCAPE_CHAR |
|
Methods
JsonStreamDecoder is a HTTP-JSON response stream decoder for JSON-ecoded protobuf messages. The response stream must be a JSON array, where the first byte is the opening of the array (i.e. '['), and the last byte is the closing of the array (i.e. ']'). Each array item must be a JSON object and comma separated.
Begins decoding the configured response stream. It is a generator which yields messages of the given decode type from the stream until the stream completes. Throws an Exception if the stream is closed before the closing byte is read or if it encounters an error while decoding a message.
Closes the underlying stream. If the stream is actively being decoded, an exception will not be thrown due to the interruption.
Details
__construct(StreamInterface $stream, string $decodeType, array $options = [])
JsonStreamDecoder is a HTTP-JSON response stream decoder for JSON-ecoded protobuf messages. The response stream must be a JSON array, where the first byte is the opening of the array (i.e. '['), and the last byte is the closing of the array (i.e. ']'). Each array item must be a JSON object and comma separated.
Generator
decode()
Begins decoding the configured response stream. It is a generator which yields messages of the given decode type from the stream until the stream completes. Throws an Exception if the stream is closed before the closing byte is read or if it encounters an error while decoding a message.
void
close()
Closes the underlying stream. If the stream is actively being decoded, an exception will not be thrown due to the interruption.