getSessionVariable: Get a variable from a client session environment

View source: R/jrc.R

getSessionVariableR Documentation

Get a variable from a client session environment

Description

This function returns a variable, how it is seen from a session, e.g. for all the received function calls and commands. It searches for the variable in the session environment first, and then, if variable is not found, checks enclosing frames of the environment, starting from the outer environment of the app (see setEnvironment). If the variable doesn't exist, throws an error.

Usage

getSessionVariable(varName, sessionId = NULL)

Arguments

varName

Name of the variable to search for. Must be a character.

sessionId

ID of the session. If there is only one active session, this argument becomes optional.

Details

This function is a wrapper around method sessionVariables of the class Session.

Value

Requested variable

See Also

setSessionVariables

Examples

## Not run: 
# to run this example an installed web browser is required
f <- function(x) {x * 3}
openPage(allowedFunctions = "f", allowedVariables = "k", sessionVars = list(k = 0))
k <- getSessionVariable("k")
getPage()$openPage(FALSE)
id1 <- getSessionIds()[1]
id2 <- getSessionIds()[2]
sendCommand("jrc.callFunction('f', [10], 'k')", sessionId = id1, wait = 3)
sendCommand("jrc.callFunction('f', [20], 'k')", sessionId = id2, wait = 3)
k1 <- getSessionVariable("k", id1)
k2 <- getSessionVariable("k", id2)

closePage()
## End(Not run)


jrc documentation built on Aug. 23, 2023, 5:10 p.m.

Related to getSessionVariable in jrc...