LexFloatClient

LexFloatClient is used in client applications to obtain floating licenses from LexFloatServer. It handles the process of requesting, renewing, and dropping license leases in your app. Before integrating LexFloatClient, make sure the LexFloatServer is installed, configured, and activated on your customer's network.

Minimum requirements

For the supported platforms, versions, and architectures, see minimum requirements.

Adding licensing to your app

Prerequisites

After you have added a product for your app in the admin portal, note its Product ID from the actions menu on the Products page. You will use this product ID in your code, and it must match the product ID configured in LexFloatServer.

For a complete, working integration, refer to the example project on GitHub.

Adding the library to your app

Download the LexFloatClient library for Windows, macOS, or Linux from the SDK downloads page. The package contains both the shared and static library.

Requesting a floating license

Set the host product ID, the LexFloatServer address, and a callback for status notifications, then request a license lease from the server. Run this whenever the user starts the app or needs a new license.

    int status;
status = SetHostProductId("PASTE_PRODUCT_ID");
if(LF_OK != status)
{
// handle error
}
status = SetHostUrl("http://localhost:8090");
if(LF_OK != status)
{
// handle error
}
status = SetFloatingLicenseCallback(LicenceRenewCallback);
if(LF_OK != status)
{
// handle error
}
status = RequestFloatingLicense();
if(LF_OK != status)
{
// handle error
}
printf("License leased successfully!");

Renewing a floating license

The license lease renews automatically in a background thread. Whenever it renews or fails to renew, your callback is invoked from that thread.

void LF_CC LicenceRenewCallback(uint32_t status)
{
switch (status)
{
case LF_OK:
printf("The license lease has renewed successfully.\n");
break;
case LF_E_LICENSE_NOT_FOUND:
printf("The license expired before it could be renewed.\n");
break;
case LF_E_LICENSE_EXPIRED_INET:
printf("The license expired due to network connection failure.\n");
break;
default:
printf("The license renew failed due to other reason. Error code: %d\n", status);
break;
}
}

Dropping a floating license

When the user is done, free the license so it becomes available to others. If you don't, the license stays leased (a zombie) until the lease expires. Run this whenever the user closes the app.

int status;
status = DropFloatingLicense();
if(LF_OK != status)
{
// handle error
}
else
{
printf("Success! License dropped.");
}

Borrowing a license for offline use

Borrowing (also known as an offline floating license) lets a user keep using licensed functionality while disconnected from LexFloatServer, for a set duration after which it expires automatically. The LexFloatServer administrator caps the lease duration with maxOfflineLeaseDuration and the number of clients that can hold an offline lease at once with allowedOfflineFloatingClients, both in config.yml.

Call RequestOfflineFloatingLicense() with the lease duration the client wants to borrow for, up to that maximum. Check for an existing lease with HasFloatingLicense() before requesting one. The license stays valid while the user is disconnected and expires automatically when the duration elapses.

For how this fits the licensing model, see on-premise floating licenses.

Next steps

Need more help?

If you need more help adding LexFloatClient to your app, we'll be glad to help you with the integration. Contact us through the contact page.

LexActivatorOverview
Last updated: