Description Details Value Methods Examples
Class providing WebSocket connection server
The most important aspect of the API of this server are methods register_action
and send_request
. These are
used to interact with the epiviz JS app through the provided websocket connection. register_action(action, callback)
registers
a callback function to be executed upon request from the epiviz JS app. When the server receives a JSON message through the websocket, it
checks for an action
field in the received request message, and then evaluates the expression callback(message_data)
where message_data
is obtained from the data
field in the received message. A response will be sent to the epiviz app with field data
populated
with the result of the callback. If an error occurs during evaluation of the callback function, the response will be sent with field
success
set to false
.
To send requests to the JS app, method send_request(request_data, callback)
should be used. This is sends a request to the JS app
with the data
field populated with argument request_data
. Once a response is received (with field success
equal to true
)
the expression callback(response_data)
is evaluated where response_data
is obtained from the data
field in the received
response message.
RC object with methods for communication with epiviz JS app
has_action(action)
Check if a callback is registered for given action<character>, <logical>. (See Details)
has_request_waiting()
Check if there is a sent request waiting for a response from JS app, <logical>
is_closed()
Check if server is closed, <logical>
is_daemonized()
Check if server is running in background, <logical>
is_interactive()
Check if server is running in interactive mode, <logical>
is_socket_connected()
Check if there is an open websocket connection to JS app, <logical>
register_action(action, callback)
Register a callback<function> to evaluate when epiviz JS sends a request for given action<character>. (See Details)
run_server(...)
Run server in blocking mode
send_request(request_data, callback)
Send request to epiviz JS app with given request_data<list>, and evaluate callback<function> when response arrives. (See Details)
service()
Listen to requests from server. Only has effect when non-daemonized
start_server()
Start the underlying httpuv server, daemonized if applicable
stop_server()
Stop the underlying httpuv server
stop_service()
Stop listenning to requests from server. Only has effect when non-daemonized.
unregister_action(action)
Unregister a callback function for given action<character> (if registered). (See Details)
wait_to_clear_requests(timeout = 3L)
Wait for timeout
seconds to clear all pending requests.
1 2 3 4 5 6 7 8 9 10 11 12 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.