Shared Variables

Shared Variables

Overview

The IS-SPX Player introduces a new mechanism called “shared variables”. This mechanism is based on a client/server model whereby a server maintains a collection of variables. The value of the variables may be updated at any time. When needed, one or more clients connect to the server to get the current value of the variables. The client can further elect to receive real-time notification when the value of those variables is updated.

The client and the server might be located on the same physical host. In this case, the shared variables are used to share information within documents. For instance, this can be used to generate interactive menus. The server might be a remote PC or another IS-SPX Player. In this case the shared variables can be used to trigger many types of events on the IS-SPX Player, such as changing the content displayed by the player, displaying a message on the screen, or the real time update of news feeds.

Concepts Behind Shared Variables

The operation of notifying the server of the list of variables for which notification is desired is called a “subscription”. Clients may subscribe and un-subscribe to variables at any time. When a client first subscribes to a variable and this variable already has a value, it will immediately receive a notification with the current value. Subsequently, the client will receive notifications each time the value has been updated, regardless of whether the value is actually different from what it was before.

The update notification always carries an absolute UTC timestamp that may be used to synchronize the action of multiple clients on a variable update. This publish and subscribe mechanism resembles the “messaging” feature of enterprise application frameworks with the exception that due to the real-time orientation only the most up to date value of a variable is distributed, so some notifications may be dropped if a newer update is available.

It is possible to subscribe to input events (mouse clicks or keyboard inputs) from an IS-SPX Player. In this case, all events received by the server will be passed to the client. For instance, it is possible using a keyboard plugged into an IS- SPX Player to control not only the attached player but also other players connected through the network. The special subscription variable “%EVENTS%” will cause event notifications to be sent instead of updates.

Javascript API

Shared variables are meant to be used with the JavaScript and NetLinx programming languages.

Interface

interface SharedVariable { readonly attribute DOMString name; readonly attribute DOMString value;

readonly attribute float lastUpdateTime; // milliseconds since Jan 1st 1970 UTC

void set( DOMString newValue );

void addUpdateListener( UpdateListener listener ); void removeUpdateListener( UpdateListener listener ); };

void UpdateListener( SharedVariable var ); interface SVGGLobal {

SharedVariable createSharedVariable( DOMString name ); };

The main API is the global createSharedVariable function, which is used both to create a local variable and to connect to a remote one.

A local variable will be stored in a non-persistent manner on the IS-SPX Player. This means that a reboot of the IS-SPX Player 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.

Inspired XPress - Programming Guide

85

 

 

Page 93
Image 93
AMX IS-SPX-1000/1300 manual Concepts Behind Shared Variables, Javascript API, Interface