The product id is the identifier of your product that is to be used in the code. The product id of the LexFloatServer and LexFloatClient must match.
Adding the library to your app
LexFloatClient wrapper for VB.NET can be easily installed through nuget:
Install-PackageCryptlex.LexFloatClient
LexFloatClient requires the Microsoft Visual C++ 2015 (or later) Runtime on older Windows versions such as Windows 7, 8, or Server 2008/2012. If not already installed, install it from the official Visual C++ Redistributable or include the required DLLs with your installer.
Setting product id
The first LexFloatClient API function you need to use in your code is SetHostProductId(). It sets the product id of the product you will be adding licensing to.
To receive a floating license, you will use SetHostUrl(), SetFloatingLicenseCallback() and RequestFloatingLicense()LexFloatClient API methods. It sets the LexFloatServer address, the callback for status notifications, contacts the server and receives the floating license.
PrivateSubleaseBtn_Click(senderAs Object,eAs EventArgs) Handles leaseBtn.Click Try LexFloatClient.SetHostProductId("PASTE_YOUR_PRODUCT_ID") LexFloatClient.SetHostUrl("http://localhost:8090") LexFloatClient.SetFloatingLicenseCallback(AddressOfLicenceRenewCallback) LexFloatClient.RequestFloatingLicense() Me.statusLabel.Text = "License leased successfully!" Catch ex As LexFloatClientException Me.statusLabel.Text = "Error code: " & ex.Code.ToString() & " Error message: " + ex.Message End TryEnd Sub
The above code can be executed every time user starts the app or needs a new license.
Renewing floating license
License lease automatically renews itself in a background thread. When a license is renewed or fails to renew, the callback is invoked (from the background thread).
Dropping floating license
When your user is done using the app, the app should send a request to free the license, thereby making it available to other users. If the app doesn't, the license becomes (zombie) useless until lease time is over.
The above code should be executed every time user closes the app.
Need more help
In case you need more help with adding LexFloatClient to your app, we'll be glad to help you make the integration. You can either post your questions on our support forum or can contact us through email.
Private Sub LicenceRenewCallback(ByVal status As UInteger)
Select Case status
Case LexFloatStatusCodes.LF_OK
Me.statusLabel.Text = "The license lease has renewed successfully."
Exit Select
Case LexFloatStatusCodes.LF_E_LICENSE_NOT_FOUND
Me.statusLabel.Text = "The license expired before it could be renewed."
Exit Select
Case LexFloatStatusCodes.LF_E_LICENSE_EXPIRED_INET
Me.statusLabel.Text = "The license expired due to network connection failure."
Exit Select
Case Else
Me.statusLabel.Text = "The license renew failed due to other reason. Error code: " & status.ToString()
Exit Select
End Select
End Sub
Private Sub dropBtn_Click(sender As Object, e As EventArgs) Handles dropBtn.Click
Try
If Not LexFloatClient.HasFloatingLicense() Then
Return
End If
LexFloatClient.DropFloatingLicense()
Me.statusLabel.Text = "License dropped successfully!"
Catch ex As LexFloatClientException
Me.statusLabel.Text = "Error code: " & ex.Code.ToString() & " Error message: " + ex.Message
End Try
End Sub