Contents - Index


4.2.1.5 Runtime Implementation

To protect your application with Sheriff you need to implement three functions: Requesting, Updating and Releasing. Each function only involves one API call. NB. For detailed information about all of the API functions click here .

Requesting

In your application, the first thing you want to do is to check that your licence is still valid. In other words, you need to request Sheriff to grant permission to run your application in the appropriate mode. SLS_Request is the function to call, it will return with various error codes if Sheriff detects that there is no valid licence on the machine. It is up to your application to take appropriate action should this happen. The demo application provides some examples.

Updating

While your application is running you need to periodically call SLS_Update to update Sheriff with the latest licence usage information, Sheriff will also update your application with the latest licence state. Updating performs two important tasks:

  • Sheriff needs to check whether the application is still up and running in order to decide whether an allocated licence resource should be reclaimed.
  • Updating ensures that the licence is valid throughout the time the application is running. This is particularly important if unit metering is being used.

Updating is often referred as 'heartbeating', to make client and server heatbeat at the same pace. As explained, updating is related to licence reclaiming. If a running application fails to update Sheriff within the predefined reclaim time, Sheriff will decide that the application is dead (E.g. crashed or deadlocked). By default, the reclaim time is set to 15 minutes; you can set your own reclaim time by calling SLS_SetOptions.

Therefore the updating interval should be shorter than the reclaim time. Typically you will set up a timer in your application and call SLS_Update in the timer message handler.

Releasing

Before your application exits, you need to call SLS_Release to notify Sheriff to release the licence resource so that it will be ready for the next application. Failing to call SLS_Release will result in a dead licence and there may be some delay before it can be automatically reclaimed by Sheriff.