Serializes data together with a JSON header into the binary
envelope expected by the JavaScript window.shidashi.fetchStreamData(id)
method.
Usage
stream_to_js(
abspath,
data,
type = c("raw", "json", "int32", "float32", "float64"),
...
)Arguments
- abspath
Character scalar. Absolute path to the target
.binfile. Usestream_path(id)to obtain a path under the app'swww/stream/directory.- data
The data to serialize. See Details for how each
typeinterprets this argument.- type
Character scalar. One of
"raw","json","int32","float32", or"float64".- ...
Additional named scalar values to embed in the JSON header and expose to the JavaScript caller via
result.header.
Details
Wire format
[endianFlag: 1 byte] [headerLen: uint32 LE] [header: UTF-8 JSON] [body]
endianFlag is always 0x01 (little-endian).
header is a JSON object containing at minimum data_type
plus any extra fields passed via ....
Body encoding by type
"raw"Passed through verbatim;
datamust be arawvector or will be coerced viaas.raw()."json"datais serialized withjsonlite::toJSON(auto_unbox = TRUE)."int32"datais coerced to integer and written as 4-byte little-endian signed integers."float32"datais coerced to double and written as 4-byte little-endian IEEE 754 single-precision floats."float64"datais coerced to double and written as 8-byte little-endian IEEE 754 double-precision floats.