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. 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 that are described bellow, via methods of the corresponding
App
object, or using 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 time stamp is generated by
Sys.time
function.
startTime
Time when this session has been started (generated by Sys.time
function).
maxN
Maximum number of messages that can be simultaneously stored for this session. Must be a single number.
If maxN = 0
, any message that requires authorization will be immediately discarded.
If message storage is full, the oldest stored message will be removed, when a new one comes in. Default
value is Inf
.
maxSize
Maximum allowed size of the message storage in bytes. Must be a single number.
If maxSize = 0
, any message that requires authorization will be immediately discarded. If message storage is full,
older messages will be removed, until either the allowed storage size is reached, or only one message remains. Default
value is Inf
.
getMessageIds()
Returns IDs of all currently stored messages. ID is combination of 6 random letters and numbers,
which is generated, when the message is stored. See also getMessageIds
.
authorize(messageId = NULL, show = FALSE)
Authorizes evaluation of the message. Check authorize
for more information.
removeMessage(messageId = NULL)
Removes a stored message. This can also be done with authorize
function (set
show = TRUE
and then select to ignore message). 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.
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.