Important Information
Supporting Cloud Zoo within your plugin’s code is easy, but it is important to understand that Cloud Zoo licensing behaves differently from other licensing methods in Rhino. With Cloud Zoo, your plugin (and Rhino itself) will not receive a license key entered by the user or a local Zoo server, but rather a cryptographically verified token called a License Lease. The License Lease is authored by Cloud Zoo and handed to Rhino when a license for your plugin is first requested, and at regular intervals thereafter. A License Lease expires every few weeks, so Rhino will automatically negotiate a new lease with Cloud Zoo and hand it to your plugin so that the lease is always a few weeks from expiring.
In addition, note that expiration is not the only way a license lease can voided. Rhino can inform your plugin that a lease has been voided for a variety of reasons (For example, the license was removed from Cloud Zoo by the user or the user starting Rhino on a different computer).
Required Steps
To support Cloud Zoo in your plugin, the following must be done in your plugin’s code:
- Implement
OnLeaseChangedDelegate
method. - Call
GetLicense
within your plugin. - Digitally sign your plugin.
Implement OnLeaseChangedDelegate
This method is called by Rhino after a license lease changes. This can happen in the following situations:
- A license lease is successfully negotiated after you call
GetLicense
. - A new license lease is negotiated automatically by Rhino to keep it from expiring.
- The current license lease expires (The lease received is null).
- The current license lease is voided by Cloud Zoo (The lease received is null).
When LicenseLeaseChangedEventArgs.Lease
is null, you should assume the user does not have a valid license and disable functionality accordingly.
Example:
/// <summary>
/// Called by Rhino to signal that a lease from Cloud Zoo has changed.
/// If LicenseLeaseChangedEventArgs.Lease is null, then the server has signaled
/// that this product is no longer licensed. Your plug-in must change behavior
/// to behave appropriately.
/// </summary>
/// <param name="args">Data passed by Rhino when the lease changes</param>
/// <param name="icon">Icon to be displayed in Tools > Options > Licenses for this lease.</param>
private static void OnLeaseChanged(LicenseLeaseChangedEventArgs args, out System.Drawing.Icon icon)
{
icon = ProductIcon;
// This sample does not support Rhino accounts.
if (null == args.Lease)
{
// Lease has been voided; this product should behave as if it has no
// license. It is up to the plug-in to determine what that looks like.
}
// Verify that args.Lease.ProductId is correct
// Verify that args.Lease.ProductEdition is correct
// Verify that args.Lease.ProductVersion is correct
// Verify thatargs.Lease.IsExpired() is false
}
Call GetLicense
Like other licensing methods, you should call GetLicense
when your plugin is loaded. The only difference is that you must pass the OnLeaseChanged
delegate you implemented in the previous step and add SupportsRhinoAccounts
to the LicenseCapabilities
argument so that Rhino can know that you support Cloud Zoo and so that Rhino can know which delegate to call when a license lease change occurs.
When calling GetLicense
, the validatedProductKeyDelegate
argument cannot be null. If you only support Cloud Zoo licensing (LicenseCapabilities.SupportsRhinoAccounts
), then use a dummy method, like below.
private static ValidateResult OnValidateProductKey(string licenseKey, out LicenseData licenseData)
{
// will not be called but must nonetheless be a valid delegate method
licenseData = null;
return ValidateResult.ErrorShowMessage;
}