| stream_to_js | R Documentation |
Serializes data together with a JSON header into the binary
envelope expected by the JavaScript window.shidashi.fetchStreamData(id)
method.
stream_to_js(
abspath,
data,
type = c("raw", "json", "int32", "float32", "float64"),
...
)
abspath |
Character scalar. Absolute path to the target |
data |
The data to serialize. See Details for how each |
type |
Character scalar. One of |
... |
Additional named scalar values to embed in the JSON header and
expose to the JavaScript caller via |
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; data must be a
raw vector or will be coerced via as.raw().
"json"data is serialized with
jsonlite::toJSON(auto_unbox = TRUE).
"int32"data is coerced to integer and written as
4-byte little-endian signed integers.
"float32"data is coerced to double and written as
4-byte little-endian IEEE 754 single-precision floats.
"float64"data is coerced to double and written as
8-byte little-endian IEEE 754 double-precision floats.
Invisibly returns abspath.
stream_path
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.