Synergex.SynergyDE.DeviceLicensing.ISynergyDeviceCallback

 

WNSupported in Synergy .NET on Windows

 

 

namespace Synergex.SynergyDE.DeviceLicensing
interface ISynergyDeviceCallback

Synergex provides a DeviceLicensing namespace that contains the functionality needed to implement device licensing in your applications. See Device Licensing for instructions. Also see Synergex.SynergyDE.DeviceLicensing.DeviceLicensing.

Methods

The ISynergyDeviceCallback interface requires you to implement three methods: Init(), ActivationDialog(), and Synchronize().

Tip

These callbacks are intended to be implemented in an asynchronous manner. Our samples and application project templates are coded this way. If the application is not successfully licensed within one hour, it will be terminated. A nag message will be displayed every 10 minutes until that time.

Init

public method Init(), @System.Threading.Tasks.Task

Called automatically at startup if the device has not yet been initialized. You must code this method to call DeviceLicensing.GetDeviceGUID(), which gets a unique device identifier from the device license service. See GetDeviceGUID for the possible return values that should be handled from a call to that method.

Upon return from this callback, if no unique identifier was stored, the Synergy device runtime will terminate the application.

ActivationDialog

ISynergyDeviceCallback.ActivationDialog, @System.Threading.Tasks.Task

Called automatically at application startup if the device has been initialized but not yet activated. You must code this method to pass the token and password associated with a license block, along with a unique device description to DeviceLicensing.Activate(). (Typically the method will prompt the device end user for this information, but it can also be used in conjunction with your application log-in process.) See Activate for the possible return values that should be handled from a call to that method. Some could be coded to trigger the application to reprompt and call Activate() again, to return to the Synergy device runtime and let it terminate the application, or to display debug information for sending to Synergex.

Upon return from this callback, if the device is neither activated nor in a grace period, the Synergy device runtime will terminate the application. (A device is considered to be in a grace period if it is within seven days of the initial attempt to activate and an error occurred on the call to DeviceLicensing.Activate().)

Synchronize

ISynergyDeviceCallback.Synchronize(blocking), @System.Threading.Tasks.Task

Called when synchronization needs to occur. If blocking (boolean) is true, execution of the application is blocked. If false, the application continues to execute. You must code this method to call DeviceLicensing.Synchronize(false), which retrieves current device license information from the device license service and stores it on the device. See Synchronize for the possible return values that should be handled from a call to that method.

Synchronize() is called at application startup under the following circumstances:

In the three cases above, Synchronize’s blocking parameter is true. When blocking is true, the application is not running; no other code (such as status bars, etc.) will be executed until the call has finished. If the Synchronize() callback returns without resolving the licensing issue, the Synergy device runtime will terminate the application. We recommend that the method be coded to handle errors returned from DeviceLicensing.Synchronize() by prompting the user to retry the synchronization, to return to the Synergy runtime and let it terminate the application, or to display debug information for sending to Synergex.

ISynergyDeviceCallback.Synchronize() is also called at application startup under these circumstances:

When called in these two cases, Synchronize’s blocking parameter is false. This means that it is not a blocking call, and the application will continue execution.

To handle cloned devices, we recommend that if DeviceLicensing.Synchronize() returns LicenseError.DeviceMismatch, it should be called again passing true for the auto_reactivate parameter. This will instruct the device license service to allocate a new slot for the device.

Examples

The following is a basic example of an ISynergyDeviceCallback implementation. Your application would probably also have prompts and different handling of errors. For a more detailed example, see the WPFDeviceLicense.zip sample, available from Synergy CodeExchange in the Resource Center on the Synergex website.

import Synergex.SynergyDE.DeviceLicensing
import System.Threading.Tasks
namespace ns1
class class1 implements ISynergyDeviceCallback
public method Init, @Task
proc
    data lerr, @Task<LicenseError>
    lerr = DeviceLicensing.GetDeviceGUID()
    lerr.Wait()
    Console.Write("GetDeviceGUID returned ")
    Console.WriteLine(lerr.Result)
    mreturn lerr
end
public method ActivationDialog, @Task
proc
    data token, string
    token = Environment.GetEnvironmentVariable("TESTDEV_TOKEN")
    data pwd, string
    pwd = Environment.GetEnvironmentVariable("TESTDEV_PWD")
    data lerr, @Task<LicenseError>
    lerr = DeviceLicensing.Activate(token, pwd, "mysite")
    lerr.Wait()
    Console.Write("Activate returned ")
    Console.WriteLine(lerr.Result)
    mreturn lerr
end
public method Synchronize, @Task
    blocking, boolean
proc
    data lerr, @Task<LicenseError>
    lerr = DeviceLicensing.Synchronize(false)
    lerr.Wait()
    Console.Write("Synchronize returned ")
    Console.WriteLine(lerr.Result)
    mreturn lerr
end
endclass
endnamespace