-
Notifications
You must be signed in to change notification settings - Fork 3
JavaScript API
This contains functions for communicating with the visualization server. Communication with the visualization server is over websockets using WAMP (Websocket Application Messaging Protocol). The details of using WAMP are handled for you by VDD Core client and server code.
Creates a websocket connection to the visualization server. Returns a session object that should be passed into the sendData
function to send data to the server.
-
vizDataHandler_or_channelsToHandlers
- This should be either a function that will receive visualization data on the default channel or a JavaScript map of channel names to functions that handle the data.
Normally a single channel is sufficient for communicating visualization data from the server to the browser. Occasionally you may want to open multiple channels. Passing in a map of channel names to separate functions will allow multiple channels. The function passed to connect
should take two arguments, topic
and data
. topic
will be a string containing the name of the visualization channel. data
will contain the visualization data sent to the browser.
var session = nil;
// Handles the visualization data sent from the server.
function onVizData(topic, data) {
console.log("Visualization data received", data);
// TODO Display the data.
}
// Connect using websockets and register callback for visualization data.
session = vdd_core.connection.connect(onVizData);
Calls a function on the server with some data. This allows making a visualization interactive in that it can drive the code on the server.
-
session
- The session object returned when connecting the server. -
server_data_fn
- A string containing the namespace and function to call on server side. ie. 'my-driver/test-code'. This will usually be a function that you define in the visualization driver. -
data
- The data to pass as an argument to the function. - [
options
] - Optional map of options:-
success
- a function to call on success -
error
- a function to call if there's an error.
-
// When some button is clicked ...
$("a#submit-logic-text").click(function (event) {
// ... grab the value in a text area
var logicStr = $("textarea")[0].value;
// ... and call boolean-logic-simplifiers/test-simplifiers with that data.
vdd_core.connection.callServerFunction(session, "boolean-logic-simplifiers.driver/test-simplifiers", logicStr);
});
TODO
TODO