I have a large dataset which is stored in binary format and I want to send chunks of data dynamically to client side JavaScript. However, when I use session$sendBinaryMessage function from server side and Shiny.addBinaryMessageHandler from client JavaScript, it shows up an error "Uncaught TypeError: Shiny.addBinaryMessageHandler is not a function".
A small example is provided as below. How can I fix the problem?
library(shiny)
runApp(
list(ui = fluidPage(
titlePanel("sendBinaryMessage example"),
fluidRow(
column(4, wellPanel(
sliderInput("controller", "Controller:",
min = 1, max = 20, value = 15),
singleton(
tags$head(tags$script('Shiny.addBinaryMessageHandler("testmessage",
function(message) {
alert("function is running properly");
}
);'))
)
))
)
)
, server = function(input, output, session){
observe({
session$sendBinaryMessage(type = 'testmessage',
message = as.raw(1))
})
})
)