Description Usage Arguments Value Details Examples
Hooks can be used to trigger certain actions when an object of a particular type is sent to the Rshare server. These hooks are simple, and can be used for a wide variety of purposes allowing for flexible interprocess communication and control between R sessions. Hooks may be created from both Rshare server sessions and client sessions using this function.
1 2 | registerRshareHook(objType, hookFunction, port = 7777,
doResponse = FALSE, overwriteExisting = FALSE)
|
objType |
name of the type/class of the objects which will trigger the hook. |
hookFunction |
the hook function. See details. |
port |
the Rshare port number. |
doResponse |
logical; whether server hook returns a
response to client when executed. Default is
|
overwriteExisting |
logical; should existing
|
invisibly returns a logical indicating whether hook registration was a success or not.
The hook function may have just two formal arguments:
obj
and optionally, port
. The object sent
to the Rshare server will be passed to the obj
argument and thus should contain all data (other than the
Rshare port number) required for the hook function. The
optional port
argument will be a single integer
specifying the Rshare port number. If port
is not
an argument to hookFunction
it will not be passed
to the hook function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Not run:
# Start Rshare server on port 7777 (the default) and register hook
startRshare()
registerRshareHook("printMsg", function(obj, port) cat("Rshare message on port",port,"-",obj$msg,"\n"))
# In a different R session, start Rshare client, and create an object of type 'printMsg'
startRshare()
obj <- list(msg="Hello World!")
class(obj) <- "printMsg"
# Send that object to the Rshare server, and watch the server session console
sendRshare(obj)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.