SDKs
...
Tutorials
Licensing Scenarios
Floating Features
9min
similar to floating licenses , licensespring supports floating features in this guide you can find an overview of the floating features functionality registering and releasing floating features and setting up the floating features watchdog check if a feature is floating as with floating licenses, you can check if a feature is floating using properties for cloud, as well as offline floating features to start, use the following code to check if a license feature is floating foreach (ilicensefeature licensefeature in license features()) { if(licensefeature isfloating || licensefeature isofflinefloating) { // do something with a floating feature } } c++ for( const auto& feature license >features() ) { if( feature isfloating() || feature isofflinefloating() ) { // do something with a floating feature } }## add getters for feature in license features() feature data = get feature data(feature) if feature data\["is floating"] or feature data\["is floating cloud"] floating slots developers will want to know the maximum number of users that can simultaneously use a floating feature and the current number of users using the feature that can be done with uint maxusers = licensefeature floatingslotscount; uint currentusers = licensefeature floatingslotsinuse;int32 t maxusers = feature floatingusers() int32 t currentusers = feature floatinginusecount();feature lkprod1f1fc1 = license get feature data("lkprod1f1fc1") feature lkprod1f1fc1\["floating timeout"] # if feature is floating type feature lkprod1f1fc1\["floating users"] # if feature is floating type floating timeout you can get information on the floating feature timeout (in minutes) and the point in time until which a registered feature is valid (time of registration + floating feature timeout) after that time, licensespring server will automatically release the feature if it's not registered again uint floatingtimeout = license floatingtimeout; datetime floatingenddatetime = license floatingenddatetime; datetime floatingenddatetimeutc = license floatingenddatetimeutc;int32 t floatingtimeout = feature floatingtimeout(); tm floatingenddatetime = feature floatingenddatetime(); tm floatingenddatetimeutc = feature floatingenddatetimeutc();feature lkprod1f1fc1 = license get feature data("lkprod1f1fc1") feature lkprod1f1fc1\["floating timeout"] feature lkprod1f1fc1\["floating end date"] feature lkprod1f1fc1\["floating start date"] registering and releasing floating features similar to floating licenses, floating features have to be periodically registered on the server for them to take up a floating slot ilicensemanager licensemanager = licensemanager getinstance(); ilicense license = licensemanager currentlicense(); ilicensefeature feature = license features() first(e => e isfloating); license registerfloatingfeature(feature); // you can find a similar sample in the console sample app // that is a part of the sdk auto licensemanager = licensemanager create( pconfiguration ); auto license = licensemanager >getcurrentlicense(); auto feature = license >features() front(); license >registerfloatingfeature( feature code() ); // you can find a similar sample in cppsample // if you wish not to add the feature to the watchdog, license registerfloatingfeature has an optional `addtowatchdog` bool parameter license check feature("feature code")// go sdk v2 ld, err = lh checklicensefeature(ctx, featurecode) note that in the c++ sdk you need to pass the feature code instead of the feature object to license registerfloatingfeature likewise, if you wish to release a feature before its timeout, you can do it like so ilicensemanager licensemanager = licensemanager getinstance(); ilicense license = licensemanager currentlicense(); ilicensefeature feature = license features() first(e => e floatingenddatetime > datetime now); license releasefloatingfeature(feature); // you can find a similar sample in the console sample app // that is a part of the sdk auto licensemanager = licensemanager create( pconfiguration ); auto license = licensemanager >getcurrentlicense(); auto feature = license >features() front(); license >releasefloatingfeature( feature code() );license release feature("lkprod1f1fc1")ld, err = lh releasefloatinglicensefeature(ctx, featurecode) in net sdk, ilicensefeature data is not refreshed after registering and releasing the feature in order to get updated values like floatingslotsinuse and floatingenddatetime you have to call ilicense features() method again the same applies to the c++ sdk you have to call license >features() again to get updated feature values watchdog setup similar to a floating license watchdog, floating features have to initialize the watchdog in order to use its functionalities once set up, you register your floating features just once and the watchdog will make sure they will not expire until you manually release them (don't forget to do that on application shut down, so you don't keep the slots occupied) you initialize the watchdog like so void watchdogcallbackmethod(licensespringexception e) { // do something } license setupfloatingfeaturewatchdog(watchdogcallbackmethod); // callback method will be invoked only if an exception in a watchdog thread // is raised if you want to invoke the callback on every feature // registration you can pass an optional parameter to the method license setupfloatingfeaturewatchdog(watchdogcallbackmethod, true);void watchdogcallback( const licensespringexception& ex ) { // do something } license >setupfeaturewatchdog( watchdogcallback );license setup feature watch dog(callback,timeout) setting up the watchdog will also start the thread if you wish to stop automatically extending your floating features, you can stop the watchdog license stopfloatingfeaturewatchdog();license >stopfeaturewatchdog();license stop feature watch dog() and once stoped, it can be restarted again license startfloatingfeaturewatchdog();license >resumefeaturewatchdog();