EpivizServer-class: EpivizServer objects

Description Details Fields Methods Author(s) See Also Examples

Description

This class encapsulates the websocket connection between the R/bioc session and the epiviz web app.

Details

Epiviz uses websockets to connect R/bioc sessions to the epiviz web app. Objects of this class encapsulates websocket objects defined in the httpuv package. The Epiviz session manager defined in class EpivizDeviceMgr calls methods in this class to send requests to the web app or to respond to requests. Can also be executed in standalone mode, serving the epiviz web app JS through the httpuv server.

Fields

port:

Port for websocket connection (default 7312)

websocket:

A WebSocket object from the httpuv package

server:

Internal use only: A server object from the httpuv package, set by the startServer method

interrupted:

Internal use only: has an interrupt been issued

socketConnected:

Internal use only: is the websocket connected

msgCallback:

Internal use only: callback functions on websocket or http requests. Created using shiny:::HandlerManager

requestQueue:

Internal use only: Queue for unsent requests

tryPorts:

Internal use only: Try more ports when opening websocket server if port requested by user is in use.

daemonized:

Internal use only: is it running in daemonized mode

standalone:

Internal use only: is it running in standalone mode

Methods

startServer(...): Sets up the server and websocket objects from httpuv package. Specifically, it sets the server field by calling startServer passing port and a set of callbacks, including a onWSOpen callback that sets the websocket field and sets the msgCallback method as the websocket$onMessage callback. In standalone mode, it also creates a callback for http requests.

stopServer(): Stops the websocket server, calling stopServer.

service(): A blocking (if not running daemonized) loop for the websocket to listen and serve requests. Calls service.

stopService(): Signals an interrupt so the service loop is stopped.

runServer(): A convenience function that runs startServer and service. stopServer is called on exit.

isClosed(): Returns TRUE if server connection is closed

bindManager(mgr): Sets the msgCallback on websocket message callback. It calls methods from argument mgr, usually an object of class EpivizDeviceMgr. Methods currently called frommgr are: getMeasurements,getRows,getValues,getSeqInfos and getAllData. The latter is used only in testing.

sendRequest(request): Converts argument request to JSON and pushes it to the requestQueue.

popRequest(): Pop a request from requestQueue and send to web app.

emptyRequestQueue(): Empties request queue.

Author(s)

Hector Corrada Bravo

See Also

EpivizDeviceMgr-class, EpivizChart-class, httpuv, startServer, service, WebSocket

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  ## Not run: 
  mgr <- list(getData=function(measurements, chr, start, end) {
                        return(chr)
                      },
              verbose=TRUE)

  server <- epivizr:::EpivizServer$new(port=7123L)
  server$bindManager(mgr)
  server$startServer()
  
  browseURL("http://localhost:7123/")
  tryCatch(server$service(), interrupt=function(int) invisible())
  
## End(Not run)

epiviz/epivizr-release documentation built on May 16, 2019, 8:18 a.m.