Learn R Programming

emuR (version 2.5.0)

serve: Serve EMU database to EMU-webApp

Description

Serves emuDB media files, SSFF tracks and annotations for EMU-webApp browser GUI http://ips-lmu.github.io/EMU-webApp/

Instructions:

Start and connect (this should happen automatically):

  • Call this function to start the server.

  • Start a suitable HTML5 capable Web-Browser (Google Chrome, Firefox,...).

  • Navigate to the EMU-Webapp URL: http://ips-lmu.github.io/EMU-webApp/.

  • Press the 'Connect' button in the EMU-webApp and connect with default URL.

  • EMU-webApp loads the bundle list and the first bundles media file, SSFF tracks and annotations.

Disconnect and stop:

  • Disconnect and stop the server with the 'Clear' button of the webapp or the reload button of your browser.

  • The server can also be stopped by calling stopAllServers of the httpuv package

Hints:

  • To serve only a subset of sessions or bundles use the parameters sessionPattern and/or bundlePattern.

  • Use the seglist parameter to pass in a segment list which was generated using the query function. This will allow quick navigation to those segments.

Usage

serve(
  emuDBhandle,
  sessionPattern = ".*",
  bundlePattern = ".*",
  seglist = NULL,
  bundleListName = NULL,
  host = "127.0.0.1",
  port = 17890,
  autoOpenURL = "https://ips-lmu.github.io/EMU-webApp/?autoConnect=true",
  browser = getOption("browser"),
  useViewer = TRUE,
  debug = FALSE,
  debugLevel = 0
)

Value

TRUE (invisible) if the server was started

Arguments

emuDBhandle

emuDB handle as returned by load_emuDB

sessionPattern

A regular expression pattern matching session names to be served

bundlePattern

A regular expression pattern matching bundle names to be served

seglist

segment list to use for times anchors and session + bundle restriction (type: emuRsegs)

bundleListName

name of bundleList stored in emuDB/bundleLists subdir to send to EMU-webApp

host

host IP to listen to (default: 127.0.0.1 (localhost))

port

the port number to listen on (default: 17890)

autoOpenURL

URL passed to browseURL function. If NULL or an empty string are passed in browseURL will not be invoked.

browser

argument passed on to browser argument of browseURL (see it's documentation for details )

useViewer

Use the viewer provided by getOption("viewer") (the viewer pane when using RStudio) and host a local version of the EMU-webApp in it. This will clone the current EMU-webApp build (https://github.com/IPS-LMU/EMU-webApp/tree/gh-pages/) into the directory provided by tempdir and serve this local version. A clone will only be performed if no file.path(tempdir(), "EMU-webApp") directory is present. An alternative directory can be also set: options(emuR.emuWebApp.dir="path/to/EMU-webApp") (use if offline functionality is required).

debug

TRUE to enable debugging (default: no debugging messages)

debugLevel

integer higher values generate more detailed debug output

Details

Function opens a HTTP/websocket and waits in a loop for browser requests. Parameter host determines the IP address(es) of hosts allowed to connect to the server. By default the server only listens to localhost. If you want to allow connection from any host set the host parameter to 0.0.0.0. Please note that this might be an safety issue! The port parameter determines the port the server listens on. The host and port parameters are intended only for expert users. When started the R console will be blocked. On successful connection the server sends the session and bundle list of the database referenced by name by parameter dbName or by UUID parameter dbUUID. The Web application requests bundle data for viewing or editing. If a bundle is modified with the EMU-webApp and the save button is pressed the server modifies the internal database and saves the changes to disk. Communication between server and EMU webApp is defined by EMU-webApp-websocket-protocol version 0.0.2 (https://ips-lmu.github.io/The-EMU-SDMS-Manual/app-chap-wsProtocol.html).

Examples

Run this code
if (FALSE) { 
## Load EMU database 'myDb' and serve it to the EMU-webApp (opens default HTTP/websocket port 17890)

myDb = load_emuDB("/path/to/myDb")
serve(myDb)
}

Run the code above in your browser using DataLab