BrowserViz: Constructor for BrowserViz

View source: R/BrowserViz-class.R

BrowserViz constructorR Documentation

Constructor for BrowserViz

Description

This constructor function:

  • creates the BrowserViz object

  • initializes the httpuv web server

  • prepares that web server to additionally handle websocket traffic

  • loads a "browserFile" - an html/javascript/css web page to communicate with in your web browser

  • opens websocket communication between your R session and your browser

  • installs an optional "httpQueryProcessingFunction" to handle http (non-websocket) requests.

Usage

BrowserViz(
  host = "localhost",
  portRange = 10000:10100,
  title = "BrowserViz",
  browserFile,
  quiet = TRUE,
  httpQueryProcessingFunction = NULL
)

Arguments

host

character The constructor will open an http/websocket port here for web browsers to connect to. localhost by default

portRange

The constructor looks for a free websocket port in this range. 10000:10100 by default

title

Used for the web browser window, "igvR" by default

browserFile

The full path to the bundled html, js and libraries, and css which constitute the browser app

quiet

A logical variable controlling verbosity during execution

httpQueryProcessingFunction

a function, default NULL, provides subclasses with the opportunity to execute code on the http server created here.

Value

An object of the BrowserViZ class

Examples

library(BrowserViz)
browserVizBrowserFile <- system.file(package="BrowserViz", "browserCode", "dist", "bvDemoApp.html")
if(BrowserViz::webBrowserAvailableForTesting()){
  bvApp <- BrowserViz(browserFile=browserVizBrowserFile, quiet=TRUE)
  data <- list(lowercase=letters, uppercase=LETTERS)
  json.returned <- roundTripTest(bvApp, data)
  data.returned <- fromJSON(json.returned)
  stopifnot(identical(data, data.returned))
  html <- sprintf("<h3>round trip of json-encoded data, %d chars</h3>",
                  nchar(json.returned))
  displayHTMLInDiv(bvApp, html, "bvDemoDiv")
  closeWebSocket(bvApp)
  }


paul-shannon/BrowserViz documentation built on Nov. 17, 2024, 1:42 p.m.