Shared Variables
Shared Variables
Overview
The
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
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
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
It is possible to subscribe to input events (mouse clicks or keyboard inputs) from an
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
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 |
|
|