Session | R Documentation |
Objects of this class handle all the incoming and outgoing messages for one active connection.
Please, avoid creating instances of this class manually. Each Session
object is created when
a WebSocket is opened and serves as a wrapper around it. A manually created object will not have
a WebSocket connection and thus are not functional.
All sessions are stored within an object of class App
and cannot exist and function without it.
One can manipulate a session directly, using its methods described below, via methods of the corresponding
App
object or the provided wrapper function (links to them can be found in the Methods section).
id
Automatically generated ID for this session. ID is a random combination of 6 letters or numbers. Please, do not change the value of this field.
lastActive
Time of the last received message from the session's WebSocket. The timestamp is generated by the
Sys.time
function.
startTime
Time when this session has been started (generated by the Sys.time
function).
getMessageIds()
Returns IDs of all currently stored messages. ID is a combination of 6 random letters and numbers
generated when the message is stored. See also getMessageIds
.
authorize(messageId = NULL, show = FALSE)
Authorizes evaluation of a message. Check authorize
for more information.
removeMessage(messageId = NULL)
Removes a stored message. This can also be done with the authorize
function (set
show = TRUE
and then select the “Ignore message” option). See also removeMessage
.
sendCommand(command, wait = 0)
Sends a JavaScript command to be evaluated on the web page. Check
sendCommand
for more information.
callFunction(name, arguments = NULL, assignTo = NULL, wait = 0, thisArg = NULL, ...)
Calls an existing JavaScript
function on the web page. Check callFunction
for more information.
sendData(variableName, variable, wait = 0, keepAsVector = FALSE, rowwise = TRUE)
Sends data and assigns it to
a variable on the web page. Check sendData
for more information.
sendHTML(html, wait = 0)
Sends HTML code that will be appended to the web page. Check sendHTML
for
more information.
sessionVariables(vars = NULL, varName = NULL, remove = NULL)
Sets or returns variables that are used (read or modified) only by this session. If both arguments are
NULL
, returns environment for this session. If vars
is a named list, adds this variables to the
session environment. If varName
is a character, returns a variable with this name how it is seen from
the session. If the variable doesn't exist, throws an error. If remove
is a vector of characters, removes
variables with these names from the session environment. One can add variables to the session environment,
get one back and remove variables with a single function call. Check setSessionVariables
,
getSessionVariable
, removeSessionVariables
for more information.
setLimits(limits)
Sets limits for memory usage, number of simultaneously active connections and amount of messages processed per second.
For information about possible arguments, please, check setLimits
. This method accepts all the same arguments,
but they should be supplied in a form of list.
Note, that Session
class has some other public methods that are not mentioned in this list. These methods are
intended to be used only by other functions of jrc
package and therefore are not documented.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.