closeSession: Close one or several client sessions

Description Usage Arguments Examples

View source: R/jrc.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)

# this will close all sessions except for the one, that has just send a command to R session
closeSession(inactive = Sys.time() - time)

# if there is only one active session, sessionId becomes an optional argument
closeSession()

closePage()

jrc documentation built on Jan. 4, 2022, 5:07 p.m.

Related to closeSession in jrc...