Offscreen Websocket mode fully supports math interactive features. This page describes the corresponding WebSockets messages.

These messages rely on a math solver controller on the server that mainly allows you to handle:

They consist in two messages: a mathSolver to perform an action on the math solver controller and its corresponding response mathSolverResult.

Sending a message to the math solver on the server

Client to server message
{
  "type": "mathSolver",
  "action": [enum] "available-actions" | "numerical-computation" | "get-diagnostic" | "get-variables" | "set-variable-value" | "get-variable-value" | "remove-variable-value" | "as-variable-definition" | "get-variable-definitions" | "get-evaluables" | "evaluate",
  "blockId": [string] <the block id>,
  "task": [string] <the action for which a diagnostic is requested>,
  "variableName": [string] <the variable name>,
  "variableValue": [double] <the variable value>
  "evaluation": {
    inputVariableName: [string] <the input variable name>,
    outputVariableName: [string] <the input variable name>,
    from: [double] <the start of the range to evaluate>,
    to: [double] <the end of the range to evaluate>,
    pointCount: [int] <the number of values to evaluate between [from, to]>
  }
}

Getting a result message from the math solver on the server

The server sends you a mathSolverResult containing the math solver result.

Server to client message
{
  "type": "mathSolverResult",
  "action": [string] <the action requested in mathSover message>,
  "result": [Object],
  "blockId": [string] <the block id>
}

Message details per action

available-actions

Returns the available actions for the specified block.

numerical-computation

Returns the output for the numerical computation of the specified block.

get-diagnostic

To help troubleshoot, the get-diagnostic gives you diagnostics on a given task and the specified block. It can be useful to understand why get-evaluables returns an empty array, by calling it with an evaluation task or to find out why available-actions does not include the numerical-computation action in the returned array, by calling it with a numerical-computation task.

It also returns a MathDiagnostic code so that your application can get information about error situations, such as computation errors, and that you can map to an error message in your application to let end users know what’s going on.

get-variables

Returns information about defined variables, associated with the specified block or from global variables.

set-variable-value

Sets the value associated with the given variable name, for the specified block or as global variable.

get-variable-value

Returns the value associated with the given variable name, for the specified block or as global variable.

remove-variable-value

Removes the definition of the given variable name, for the specified block or as global variable.

as-variable-definition

Checks if the specified block represents a variable definition and returns the associated information.

get-variable-definitions

Returns the list of all variable definitions.

get-evaluables

Returns the list of variable names that can be evaluated in the specified block. An expression is evaluable if it can be interpreted as a function of a given variable:

The message content is:

evaluate

Returns the list of points resulting from evaluating the given variables in the specified block. This allows to get plot-ready coordinates that can be used to plot graphs using a graphics library.