rcloud.session.info {rcloud.support} | R Documentation |
rcloud.session.info
retrieves information about an RCloud session.
rcloud.session.info(id = .session$sessionID, user = .session$username)
id |
session id, defaults to the current session |
user |
username of the user owning the session, defaults to the current user |
Each connection to RCloud creates a session. A session is specific to a user and running on a specific machine. As such it has all the unix properties such as pid, uid, gid. In compute separation setup the current session will be the compute session (although the control session also exists in parallel).
The mode of the session determines what kind of session was initialized. This allows the notebook to determine how it is being run. Althoiugh the mode can be set to anything in the client the following modes are most often used in regular RCloud:
IDEis the mode used by the RCloud UI - both in edit and view mode
callis used when calling a notebook via the
rcloud.call.notebook
API
clientis used by JavaScript clients (mini, shiny etc.)
scriptis used when running RCloud sclipt on the command line
startupshould never be seen under normal circumstances - this is the initial mode value before the mode is set by the connection
A list with at least the following entries
id |
session ID (typically a GUID) |
host |
name of the host running the session |
script.url |
URL to the script service on that host. Note that this is only guaranteed to be valid on the RCloud node, generally it cannot be used from a client |
pid |
process ID of the session |
uname |
unix username |
uid |
unix user id |
gid |
unix group id |
user |
notebook store username |
mode |
type of the session (see Details section) |
start |
timestamp of the session start |
Simon Urbanek
str(rcloud.session.info())
# use direct output in IDE and RCloud Web otherwise
# so that we see output in both cases
if (rcloud.session.info()$mode == "IDE") {
rcloud.html.out("<h2>Hello, World!</h2>")
} else {
rcloud.web::rcw.result(body="<h2>Hello, World!</h2>")
}