Skip to main content
Documentation - Limelight XE™ - Tutorial
Tutorial
Accessing Object Properties in Scripts

Overview

This is a tutorial on how to access Limelight XE™ object properties from a script running on the embedded JavaScript engine in the ACE service.

Prerequisites

Lesson 1

Limelight XE comes complete with an embedded ECMAScript 6 compliant JavaScript engine that has been expanded to access all the internal modules of the server.  Scripts run with administrative rights which must be considered when deploying applications.  To allow access to objects and their associated properties, the language was extended to provide additional mechanisms to read and alter these properties.  Since the language extensions include an optional ServerGUID, properties can be obtained and altered on any Limelight XE server connected via the Inter-Connection Manager.

See the basic example below.  The code showcases one of several extensions namely getProperties().  For details on these functions, see the Scripting API.  The code first clears the debug console (visible at the bottom of the file editor window when editing scripting source) and then assigns all the property objects to the variable obj.  It then dumps all the property object names and values to the console.  

// Default Limelight Javascript Shell
(()=>{  // main script begins...
 // -- constants --
 // GUID of the System Management object
 const objectGUID = '{759161EB-1000-0000-0000-000000000000}';
 // -- operational code begins here --
 console.clear(); // clear the console log
 // get all the properties of the System Management object
 var obj = ace.getProperties(ace.this.serverGUID, objectGUID);
 // if it exists, process the needed info
 if (typeof obj != 'undefined') {
  // simply dump everything for testing
  for (var property in obj) {
   // for now list the properties and their values
   console.log(' - ' + property + '=' + obj[property]);
  }
 }
})(); // end of main script...

Exercise 1

  1. Using the Limelight XE Console, log into your Limelight XE server with administrator rights.
  2. Click on the Components Tab and on the left tree view, expand the tree to expose the Script Manager under System Management.
  3. Right mouse click on the Script Manager, a pop-up menu will appear - click New to create a new script.
  4. Double click on the new file name that was added to the Script Manager list (or right click on the new file name and select Edit) - the File Editor tab will appear to the right.
  5. Copy and paste the above code into the file editor and click Update (bottom right).
  6. Test your code by running it and watching the  console log - click Run.
  7. You should see a list of all the System Management properties.
  8. If you were successful in accessing the System Management properties then experiment by replacing the GUID value with other object GUIDs in the system and see what happens.

Lesson 2

Obviously it is important to be able to obtain the value of an object's property, but it is equally important to be able to alter it.  The language extensions also provide this capability using the setProperty() function. See the example below on how to set a global variable's value.

// Default Limelight Javascript Shell
(()=>{  // main script begins...
 // -- constants --
 // GUID of a global variable - note use the GUID of your global var
 const objectGUID = '{759161EB-1005-0010-0000-000000000001}';
 // -- variables --
 var v;
 var vn;
 // -- operational code begins here --
 console.clear(); // clear the console log
 // get all the properties of the System Management object
 var obj = ace.getProperties(ace.this.serverGUID, objectGUID);
 // if it exists, display the global variable's value and then alter it
 if (typeof obj != 'undefined') {
  // display the value
  console.log('Value=' + obj.Value);
  // change it
  v = parseInt(obj.Value) + 1;
  // show what we want it to be
  console.log('Target value=' + v);
  // now change it
  ace.setProperty(ace.this.serverGUID, objectGUID, 'Value', v);
  // get the value again
  obj = ace.getProperties(ace.thisGUID, objectGUID);
  vn = parseInt(obj.Value);
  // show that it changed
  console.log('New value=' + vn);
 }
})(); // end of main script...

This code will read a global user variable (note the GUID of that object must match what you create in the Global Variables object - it also assumes it is an integer), increment it by one and then store it back.  It then reads the object again to confirm the value was updated.

Exercise 2

  1. Using the Limelight XE Console, log into your Limelight XE server with administrator rights.
  2. Click on the Components Tab and on the left tree view, expand the tree to expose the System Manager / User Defined Variables / Global Variables object.
  3. Right click on the Global Variables object and create a new variable.
  4. In the properties of the new variable, set the Value property to zero (0) - optionally give it a unique name.
  5. Now navigate back to the Script Manager and modify the code from the previous lesson with the above example.
  6. Alter the objectGUID to match that of the newly created global variable.
  7. Run the script - it should now show the global variable being incremented by one on each run of the script.
  8. Confirm it is being altered by navigating to the new Global Variable and examine it's Value property.
Related Topics

About

Strasis Systems, LLC is a provider of software for command and control centers, data visualization, security and systems integration.