This is documentation of an archived release.
For documentation on the current version, please check Knowledge Base.

Example : Check Product License

This example assumes you have successfully embedded the component.

Every seat of your application must be activated before it can be used. During the license check, the user will be asked for an Activation Key or a Publisher Server that can provide an Activation Key instead. This activation key will be validated online and the license will then be granted or revoked.

The activation key is stored in the Flash Local Storage and does not need to be entered again later.

Steps to take :

  1. Set Product ID and Developer ID
  2. Set a License Server (optional)
  3. Check the license
  4. Listen to validation events

1. Set Product ID and Developer ID

As a developer you should identify yourself and the product you are creating, using the setDeveloperId() and setProductID() methods.

client.setDeveloperId(<developerId>);
client.setProductId(<productId>);

2. Set License Server (optional)

When your application is always connecting to the same Publisher, you can let the Publisher server provide activation keys to your clients. You can use the setLicenseServer() method to setup the Publisher server you want to use.

Note that when you use a License Server to activate, the webclient can only connect to that Publisher.

client.setLicenseServer(<publisherUrl>);

3. Initiate the license check.

Execute the license check using checkLicense().

client.checkLicense();

4. Listen to validation events

The checkLicense() function will result in a LicenseEvent.GRANTED or LicenseEvent.REVOKED event being dispatched from the main Client object.

In case of a failed license check, the LicenseEvent.REVOKED event will be dispatched. This event has a property named 'statusCode' that indicates why the license check has failed. For a full list of status codes, please consult the API.

client.addEventListener(orbit.webclient.LicenseEvent.GRANTED,
    function(e)
    {
        // Start using the API.
        console.log("License granted.");
    });          
client.addEventListener(orbit.webclient.LicenseEvent.REVOKED,
    function(e)
    {
        // License revoked.
        console.log("License revoked : "+ e.statusCode);
    });          

Result

Check your browser console to see license granted/revoked feedback.

 
Last modified:: 2019/03/25 11:36