jrc (version 0.3.0)

closeSession: Close one or several client sessions

Description

Closes websocket connections for the selected client sessions and removes all the related information from memory. If no arguments are provided and there is only one active session, closes it. This function is a wrapper around method closeSession of class App.

Usage

closeSession(sessionId = NULL, inactive = NULL, old = NULL)

Arguments

sessionId

IDs of the sessions to close. Can be a vector of multiple IDs.

inactive

All sessions that were inactive (didn't receive any messages) for the specified amount of time (in seconds) will be closed.

old

All sessions that were opened for at least specified amount of time (in seconds) will be closed.

Examples

Run this code
# NOT RUN {
start <- Sys.time()
openPage()

app <- getPage()
time <- Sys.time()

app$openPage(FALSE)
app$openPage(FALSE)

print(getSessionIds())

# No sessions will be closed
closeSession(old = Sys.time() - start)
print(getSessionIds())

# One session (the one that has been opened first) will be closed
closeSession(old = Sys.time() - time)
print(getSessionIds())

time <- Sys.time()
sendCommand("jrc.sendCommand('print(\"Hi!\")')", sessionId = getSessionIds()[1],  wait = 3)

closeSession(inactive = Sys.time() - time)
closeSession()

closePage()
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab