SDKs
...
Tutorials
Licensing Scenarios

Floating Licensing

20min
licensespring enables developers to generate licenses for concurrent usage among application users, using licensespring as the floating license server see floating licenses docid 4aunypial8i2te4nyppx7 for more information about floating licensing this guide offers a fundamental overview of how to leverage the floating cloud functionality this includes instructions on how to register and deregister a floating cloud license, manage timeouts, and implement license borrowing by the end of this tutorial, readers will understand when to use floating licenses and how to implement handling of a cloud floating license within their applications prerequisites completed the getting started tutorials, specifically initialized licensemanager (or licensehandler) with your configuration using the appropriate settings activated a license creating a floating license the default maximum simultaneous license users and floating timeout period are setting during product creation selecting floating cloud and setting timeout and max simultaneous users it is also possible to edit these default values when issuing a license editing default values when issuing license floating license data floating licenses encompass a multitude of distinctive fields that are specific to this licensing model these fields are tailored to the dynamic nature of floating licenses and are designed to cater to the flexible allocation, sharing, and management of software licenses across multiple users and devices checking if a license is floating first, developers are able to check whether a license is floating using the following if ( license >isfloating() ) //license is floatingif ( licenses isfloating() ) //license is floatinglicense isfloatingif license is floating() pass checking maximum floating users our sdks offer the ability to check the maximum simultaneous license users with license >maxfloatingusers();license floatingslotscount();license maxfloatinguserslicense max floating users() note only query this value after online license check or registration (for offline floating) if this value is reached and another 'checkout' is attempted, our sdks will throw a maxfloatingreachedexception retrieving number of floating licenses in use our net and c++ sdks also allow developers to check the number of floating licenses currently in use with license >floatinginusecount();license floatingslotsinuse();license floatinginusecountlicense floating in use devices() floating timeout the floating timeout determines the timeout duration for a floating license in minutes the sdk doesn't refresh the floating license when it times out by default to enable this feature, set up the floating license watchdog the floating timeout and floating license validity end date time (in local time and utc) can be fetched with //floating timeout license >floatingtimeout(); //end date time license >floatingenddatetime(); license >floatingenddatetimeutc();//floating timeout license floatingtimeout(); //end date time license floatingenddatetime(); license floatingenddatetimeutc();license floatingtimeout license floatingenddatelicense floating timeout() registering a license in contrast to a floating server setup, a floating cloud license demands individual activation on every device aiming to utilize the license therefore, when establishing your floating cloud license arrangement, it is strongly advised to align the "max activations" parameter with or exceed the count specified in the "max simultaneous license users" field after activation, the registration process through the sdk becomes straightforward you have the choice of employing the dedicated registration method or conducting an online check, both of which serve to register your access to the floating cloud license auto license = licensemanager >getcurrentlicense(); license >registerfloatinglicense(); //or license >check();var license = licensemanager currentlicense(); license registerfloatinglicense(); //csharp does not have a dedicated register function use check instead license check(); license license = licensemanager getcurrent(); //java does not have a dedicated register function use check instead license = licensemanager checklicense( license ); try license registerfloatinglicense()license = manager load license() license check() local checks in the c++ and net sdks, since they are routinely called, confirm that a floating license timeout or borrowing period has not expired if one of them have expired, the local check throws a floatingtimeoutexpiredexception watchdog setup while conventional floating timeouts can suit certain applications, they necessitate manual implementation of checks and register api calls within the codebase a case in point is when developers embed online checks for each feature in the code if a user refrains from utilizing any features for a specific duration, they are timed out and their license is relinquished back to the license pool nevertheless, a more practical approach involves the setup of a background thread, which functions perpetually at set intervals to conduct online checks this method ensures proactive license validation, enhancing user experience by eliminating the need for active feature usage and preventing unintended timeouts license >setuplicensewatchdog( callback, timeout );license setuplicensewatchdog( callback, timeout ); //using licensewatchdogsettings class license setuplicensewatchdog( watchdogsettings );//in java, this feature needs to be turned on within the configuration object using enableperiodiccheck() and checkperiod(timeout) licensespringconfiguration configuration = licensespringconfiguration builder() apikey( apikey ) productcode( productcode ) sharedkey( sharedkey ) appname( appname ) appversion( appversion ) enableperiodiccheck( true ) checkperiod( timeout ) build();license setup license watch dog(callback,timeout) note the parameters in the setuplicensewatchdog() method consist of the callback function that will be called back in case off errors, and the timeout in minutes (which is how often online checks are performed) in the net sdk, there is a class, licensewatchdogsettings , that holds the settings of the license watchdog and can be used as the lone parameter the licensewatchdogsettings class consists of the following properties handlenointernet boolean that indicates if you want to run license checks more often if networkexception or licenseserverexception are encountered nointernettimeout custom watchdog timeout in seconds for the case if networkexception or licenseserverexception are encountered runcallbackoneverycheck boolean that indicates if you want to run the callback after every check timeout timeout in minutes, 0 means use default watchdogcallback licensewatchdogcallback object, which is a function to be called in case of errors or after every check watchdogexception called if watchdog thread cannot be started license borrowing license borrowing facilitates users in temporarily "checking out" a floating license directly from the license server this permits the utilization of the license for a defined period once the license is no longer required or when the predetermined time elapses, the user can proceed to "check in" the license for more information, see our floating licenses docid 4aunypial8i2te4nyppx7 documentation floating licenses can be borrowed using two different methods defining the hours and days from current time that the user will borrow the license for defining end date in utc in format "%y %m %dt%h %m %sz", for example "2022 05 28t15 30 00z" below are the programmatic steps required to implement license borrowing using both strategies //1 license >borrow( hours, days ); //2 std string expirydate = "2022 05 28t15 30 00z" license >borrow( expirydate );//1 license borrow( hours, days ); //2 var expirydate = "2022 05 28t15 30 00z" license borrow( expirydate );try license borrow(for 24 60 60) // 1 day license floating borrow("2031 05 06t00 00 00z") // go sdk v2 // specify the borrow duration in hours and days // alternatively, use a custom timestamp like // t = time now() add(3 time hour) utc() // ld, err = lh borrow(ctx, \&t) ld, err = license handler borrowhoursanddays(ctx, 3, 0) note with strategy 2 (using an end date in utc), if the string is left empty, then the license will be borrowed for max possible period in c++ and net, the borrowlicenseexception is thrown if borrowing is not allowed or the provided borrowing period is larger than the maximum when borrowing a license, it's worth mentioning the divergent behaviors of the license watchdog in different programming contexts in c++, the license watchdog ceases operation upon borrowing, while in net, it temporarily pauses to avoid interfering with the borrowed license's usage returning the floating license given the finite availability of registration slots, it's crucial to release these spots when not in active use to facilitate this, the process of deregistering a license becomes vital, enabling other users to register their licenses on their respective devices much like the procedure for registering a floating license, there are several approaches to accomplish license deregistration/release one option involves manually initiating the deregistration process within your code, allowing you to efficiently free up a registration slot associated with a floating license license >releasefloatinglicense( false );license release( false );try license releasefloatinglicense()license floating release(false)// go sdk v2 ld, err = licesen handler releasefloatinglicense(ctx) note the boolean parameter in these manual license release determines whether this method should throw exceptions by default, it is false alternatively, you have the option to leverage the auto release functionality this feature ensures that whenever your license object undergoes destruction, the associated floating license is automatically released from the device this proves beneficial because in scenarios such as application closure or crashes, the license object is typically destroyed, facilitating an automatic release of the license notably, this feature is already activated by default within the sdk, contributing to streamlined license management //you can use the parameter to manually turn on/off the auto release feature license >setautorelease( true ) if( license >isautoreleaseset() ) { //do something } note the parameter in setautorelease() is used to indicate whether the sdk should automatically release floating license in the destructor