Create a websocket server and bind it to a port.
create_server(port = 7681L, webpage = static_file_service(paste(system.file(package = "websockets"), "basic.html", sep = "//")), is.binary = FALSE) createContext(port = 7681L, webpage = static_file_service(paste(system.file(package = "websockets"), "basic.html", sep = "//")), server = TRUE, is.binary = FALSE)
The service port number.
Optionally, specifiy a function to service HTTP requests. This value may be NULL.
Set FALSE if the environment will represent a client connection (used internally by the
The websocket connection binary transport flag.
The websockets package supports an arbitrary number of servers, each listening
on a distinct TCP port number. An environment is associated with each running
server. Server events must be serviced with the
The webpage callback must be a function of two arguments,
socket argument indicates the low-level socket
descriptor of the client. The
header argument contains a parsed HTTP
request header. When invoked, the function may examine the request and respond
An environment is returned. The R/Websocket service will search the environment
for callback functions named:
closed functions must take a single
argument (a websocket).
receive function must take three arguments: DATA, WS, and '...',
holding the message data, websocket client, and possible
ancillary information received.
The callback functions are optional. When a websocket event occurs, the
corresponding function will be evaluated if it exists.
The DATA parameter holds a RAW vector with incoming data from broadcast
or receive events, and may be of length zero for other events.
The WS parameter is the client web socket corresponding to the event.
set_callback function for more information.
B. W. Lewis <[email protected]>
# See the detailed example in help('websockets').
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.