Specifications
Shared Variables
98
AMX InspiredSignage XPress Programming Guide
A local variable will be stored in a non-persistent manner on the IS-SPX-1000. This means that a reboot of the
IS-SPX-1000 will reset all shared variables to empty values. Local variables can be accessed from remote
clients only when the network API of the player is enabled.
To connect to a remote variable, the name parameter must contain the variable name followed by '@' and the
hostname of the variable server. Optionally, a TCP port should be added if the port number on the server is
different from the port number on the local host, e.g: text@remotehost:4567.
The function createSharedVariable returns a SharedVariable object that should be used to install “listeners”.
Those are callbacks that will be called whenever the variable value changes. The callback is passed a reference
to the variable object and can query the value property. It is also possible to poll on the lastUpdateTime
property (initially 0) to detect when the value has been updated.
The set method is used to update the value of a variable. It will trigger any callback installed on the same
variable object or on other variable objects created with the same name, including remote objects if networking
is enabled.
Sample Code
Setting the variable
On the player that controls the variable
var v=createSharedVariable( 'XY' );
v.set( 'new value' );
Reading the variable
When the same player sets and read the variable:
function onUpdate( x ) {
// Do something based on x.value
}
var v=createSharedVariable( 'XY' );
v.addUpdateListener( onUpdate );
When a player sets the variable and another player reads its content:
function onUpdate( x ) {
// Do something based on x.value
}
var v=createSharedVariable( 'XY@controller' );
v.addUpdateListener( onUpdate );