Enable real-time data sharing between SVG documents on the same player, across players, and with external systems.
JavaScript API
var sv = createSharedVariable('myVariable'); | Property/Method | Description |
|---|---|
sv.value | Current value (read-only) |
sv.set(value) | Set the variable value |
sv.addUpdateListener(fn, timeSync) | Register update handler; timeSync is a boolean, default true |
sv.removeUpdateListener(fn) | Unregister handler |
sv.testAndSet(expected, new) | Set new only if the current value equals expected |
Listen & Display
$(function() {
var display = $.headlineTextArea({}).addTo('svg');
var sv = createSharedVariable('message');
sv.addUpdateListener(function() {
display.text(sv.value);
});
display.text(sv.value || "Waiting...");
});Shared Variables are saved to localStorage automatically since firmware 3.1.0.
Network API
External clients can access the SV server via network. Disabled by default — enable in Control Center under Advanced Applications → Network API. Firmware 4.3.0 and later also offer a secure server (CoAP over TLS-PSK, port 5684).
Remote Update via RPC (AJAX)
$.ajax({
type: "POST", url: "http://HMP_ADDRESS/rpc",
contentType: 'application/json',
data: JSON.stringify({
method: "webstorage_set",
params: [[ { name: "myVar", value: "NewValue" } ]], id: 1
})
});Related Pages
- Interactive Content — cross-document control
- Web Storage — localStorage persistence
- Data Feeds & AJAX — RPC calls
- Player APIs — network API overview
SpinetiX Wiki Reference
Real-time data exchange between documents and players — createSharedVariable, listeners, network API.