websocket
websocket | R Documentation |
#
Websocket for 'sketch' applications#
DescriptionThis combines the *-Server family of functions in 'httpuv' with the transpilation functionality provided by 'sketch'.
#
Public fieldsapp
A list of functions that define the application.
server
A server handle to be used by 'stopServer'.
log
A character vector that keep tracks of all the commands sent to the
browser session.
ws
A WebSocket channel to handle the communication between the R session
and the browser session.
in_handler
A function to handle instructions sent by the browser session.
out_handler
A function to handle instruction sent to the browser session.
env
An environment to store variables temporarily.
port
An integer; the TCP port number.
message
TRUE or FALSE; whether to display a prompt when a server is started and
when it is stopped.
connected
TRUE or FALSE; whether a connection has been established. One should
ways start the WebSocket server before visiting the web page that
connects to the server.
started
TRUE or FALSE; whether a server has been started. Use the startServer
method to start a server.
#
Methods#
Public methodsstartServer()
#
Method Start a WebSocket server
#
UsagestopServer()
#
Method Stop a WebSocket server
#
UsagelistServers()
#
Method List all running WebSocket servers
#
UsagestopAllServers()
#
Method Stop all running WebSocket servers
#
Usagesketch_mode()
#
Method Enter sketch mode, in which all commands go through the transpiler before reaching the browser session.
#
Usagenew_app()
#
Method Create a blank HTML page with interactive access. This function is designed for newcomers.
#
Usage#
Argumentspreamble
(Optional) A named list; the preamble to include. Use the name 'lib' for
arguments to load_library
, 'script' for arguments to load_script
and
'data' for arguments to load_data
. Note that the "dom" and "websocket"
modules are required and loaded by default.
...
Extra parameters to pass to source_r.
#
ReturnsThe (invisible) temporary file path to the app.
new()
#
Method Initialise a WebSocket connection
#
Usage#
Argumentsin_handler
A function to handle incoming message, default to be print which only
displays the message without any processing.
out_handler
A function to handle outgoing message, default to be compile_exprs
which transpiles R commands into JavaScript commands.
message
TRUE or FALSE; whether to display a prompt when a server is started and
when it is stopped.
port
An integer; the TCP port number.
#
ReturnsA 'websocket' object.
#
Examplesclone()
#
Method The objects of this class are cloneable with this method.
#
Usage#
Argumentsdeep
Whether to make a deep clone.