Description Details Fields Methods Web App Requests Author(s) See Also Examples
This class encapsulates the websocket connection between the R/bioc session and the epiviz web app.
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. Requests are created by this class, so actions defined in the JS side are paralleled closely here (this makes the EpivizDeviceMgr) independent of the specifics in the JS side.
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 function on websocket message receive, set by bindMgr
method
requestQueue
:Internal use only: Queue for unsent requests
tryPorts
:Interval use only: Try more ports when opening websocket server if port requested by user is in use.
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.
stopServer()
: Stops the websocket server, calling stopServer
.
service()
: A blocking 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
. At minimum it must be a list
with components verbose
and getData
.
sendRequest(request)
: Converts argument request
to JSON and sends through websocket
if connected, otherwise, adds to requestQueue
.
sendRequestsInQueue()
: Sends all requests currently in the request queue.
emptyRequestQueue()
: Empties request queue.
In all below, requestId
is a callback function id set by the session manager.
addMeasurements(requestId, msType, measurements)
: adds a set of measurements to the web app. msType
indicates the type of measurement, see the typeMap
field of EpivizDeviceMgr
objects for valid measurement types. measurements
is a named character
vector of measurement names. names(measuremnts)
are the measurement ids.
rmMeasurements(requestId, measurements, msType)
: removes a set of measurements. Arguments are as addMeasurements
above.
addChart(requestId, chartType, measurements)
: adds a chart to the web app. chartType
indicates the type of chart to add, see EpivizChart-class
for valid chart types. measurements
is a character
vector containing measurement ids displayed in the chart.
rmChart(requestId, chartId)
: removes chart from the web app.chartId
specifies the id of the chart to remove. This is returned in response to an addChart
request.
clearChartCaches(requestId, chartIds)
: clears data caches for given charts. Used when objects in R/bioc session are updated.chartIds
is a vector of chart ids.
navigate(requestId, chr, start, end)
: Make web app navigate to given genomic region.
Hector Corrada Bravo
EpivizDeviceMgr-class, EpivizChart-class, httpuv, startServer, service, WebSocket
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.