Skip to content

Commit 63f03a4

Browse files
author
Kyrylo
committed
Remove floating license from examples
1 parent 5455e88 commit 63f03a4

File tree

9 files changed

+90
-325
lines changed

9 files changed

+90
-325
lines changed

examples/c/include/snippets/license/floating_license.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/c/src/main.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525

2626
#include <snippets/live/live_barcode.h>
2727

28-
static const int SCANBOTSDK_LICENSE_CHECK_TIMEOUT_MS = 15000;
29-
static const int DEREGISTER_DEVICE_TIMEOUT_MS = 15000;
30-
3128
int main(int argc, char *argv[]) {
3229
if (argc < 3) {
3330
print_usage(argv[0]);
@@ -54,14 +51,6 @@ int main(int argc, char *argv[]) {
5451
scanbotsdk_error_code_t ec = scanbotsdk_initialize(&params);
5552
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "initialize: %d: %s\n", ec, error_message(ec)); goto cleanup; }
5653

57-
// Wait for the online license check to complete.
58-
// scanbotsdk_initialize() is non-blocking and triggers the license validation
59-
// asynchronously in the background. Without waiting here, the license status
60-
// may still be unknown or incomplete, which can lead to incorrect assumptions
61-
// about license validity.
62-
ec = scanbotsdk_wait_for_online_license_check_completion(SCANBOTSDK_LICENSE_CHECK_TIMEOUT_MS);
63-
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "license_wait: %d: %s\n", ec, error_message(ec)); goto cleanup; }
64-
6554
if (strcmp(category, "scan") == 0) {
6655
if (!file_path) { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; goto cleanup; }
6756

@@ -119,18 +108,5 @@ int main(int argc, char *argv[]) {
119108

120109
cleanup:
121110
scanbotsdk_image_free(image);
122-
// For floating licenses it is highly recommended to call device deregistration.
123-
// This releases the license slot on the server, allowing other devices to activate.
124-
// If scanbotsdk_deregister_device() is not called, the license will remain occupied
125-
// by this device for some time that corresponds to the interval between license
126-
// checks (usually about 15 minutes). During this period other devices may not be
127-
// able to activate and "device slots exceeded" errors can occur.
128-
scanbotsdk_deregister_device();
129-
130-
// Wait for deregistration to complete to ensure the slot is actually released.
131-
// If this call returns SCANBOTSDK_ERROR_TIMEOUT, the deregistration did not
132-
// finish within the timeout (e.g. due to network issues), and the license may remain
133-
// locked on the server.
134-
scanbotsdk_wait_for_device_deregistration_completion(DEREGISTER_DEVICE_TIMEOUT_MS);
135111
return (ec == SCANBOTSDK_OK) ? 0 : 1;
136112
}

examples/c/src/snippets/license/floating_license.c

Lines changed: 0 additions & 72 deletions
This file was deleted.

examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import java.util.Map;
1515

1616
public class ScanbotSDKExample {
17-
static final int SCANBOTSDK_LICENSE_CHECK_TIMEOUT_MS = 15000;
18-
1917
public static void main(String[] args) throws Exception {
2018
if (args.length < 2) {
2119
ExampleUsage.print();
@@ -37,71 +35,64 @@ public static void main(String[] args) throws Exception {
3735
final String writablePath = ".";
3836

3937
ScanbotSDK.initialize(licenseKey, writablePath);
40-
ScanbotSDK.waitForOnlineLicenseCheckCompletion(SCANBOTSDK_LICENSE_CHECK_TIMEOUT_MS);
4138

4239
LicenseInfo licenseInfo = ScanbotSDK.getLicenseInfo();
4340
System.out.println("License Status: " + licenseInfo.getStatus());
44-
45-
// If you are not using floating license, it is not required to use io.scanbot.sdk.DeviceSession as there is no
46-
// need to notify server you are no longer using the license. Alternatively, you can manually call
47-
// io.scanbot.sdk.ScanbotSDK.deregisterDevice and io.scanbot.sdk.ScanbotSDK.waitForDeviceDeregistrationCompletion if you need asynchronous
48-
// deregistration behaviour
49-
try (DeviceSession ignored = new DeviceSession(DeviceSession.DEFAULT_CLOSE_TIMEOUT_MS)) {
50-
switch (category) {
51-
case "scan": {
52-
if (file == null && resource == null) { ExampleUsage.print(); return; }
5341

54-
// NOTE: Using try-with-resources on ImageRef is optional, since images are also
55-
// released when their parent container is closed. However, because images are
56-
// stored compressed and decompressed on first access, it’s better to close them
57-
// early to avoid keeping too many decompressed images in memory.
58-
try (ImageRef image = Utils.createImageRef(file, resource)) {
59-
switch (subcommand) {
60-
case "barcode": DetectBarcodesSnippet.run(image); break;
61-
case "document": DetectDocumentSnippet.run(image); break;
62-
case "check": CheckScannerSnippet.run(image); break;
63-
case "credit_card": CreditCardScannerSnippet.run(image); break;
64-
case "document_extractor": DocumentDataExtractorSnippet.run(image); break;
65-
case "medical_certificate": MedicalCertificateScannerSnippet.run(image); break;
66-
case "mrz": MrzScannerSnippet.run(image); break;
67-
case "ocr": OcrSnippet.run(image); break;
68-
case "text_pattern": TextPatternScannerSnippet.run(image); break;
69-
case "vin": VINScannerSnippet.run(image); break;
70-
default: ExampleUsage.print();
71-
}
72-
}
73-
break;
74-
}
75-
case "analyze": {
76-
if (file == null && resource == null) { ExampleUsage.print(); return; }
42+
switch (category) {
43+
case "scan": {
44+
if (file == null && resource == null) { ExampleUsage.print(); return; }
45+
46+
// NOTE: Using try-with-resources on ImageRef is optional, since images are also
47+
// released when their parent container is closed. However, because images are
48+
// stored compressed and decompressed on first access, it’s better to close them
49+
// early to avoid keeping too many decompressed images in memory.
50+
try (ImageRef image = Utils.createImageRef(file, resource)) {
7751
switch (subcommand) {
78-
case "analyze_multi_page": AnalyzeMultiPageSnippet.run(file, resource); break;
79-
case "crop_analyze": CropAndAnalyzeSnippet.run(file, resource, save); break;
52+
case "barcode": DetectBarcodesSnippet.run(image); break;
53+
case "document": DetectDocumentSnippet.run(image); break;
54+
case "check": CheckScannerSnippet.run(image); break;
55+
case "credit_card": CreditCardScannerSnippet.run(image); break;
56+
case "document_extractor": DocumentDataExtractorSnippet.run(image); break;
57+
case "medical_certificate": MedicalCertificateScannerSnippet.run(image); break;
58+
case "mrz": MrzScannerSnippet.run(image); break;
59+
case "ocr": OcrSnippet.run(image); break;
60+
case "text_pattern": TextPatternScannerSnippet.run(image); break;
61+
case "vin": VINScannerSnippet.run(image); break;
8062
default: ExampleUsage.print();
8163
}
82-
break;
8364
}
84-
case "classify": {
85-
if (file == null && resource == null) { ExampleUsage.print(); return; }
86-
try (ImageRef image = Utils.createImageRef(file, resource)) {
87-
switch (subcommand) {
88-
case "document": DocumentClassifierSnippet.run(image); break;
89-
default: ExampleUsage.print();
90-
}
91-
break;
92-
}
65+
break;
66+
}
67+
case "analyze": {
68+
if (file == null && resource == null) { ExampleUsage.print(); return; }
69+
switch (subcommand) {
70+
case "analyze_multi_page": AnalyzeMultiPageSnippet.run(file, resource); break;
71+
case "crop_analyze": CropAndAnalyzeSnippet.run(file, resource, save); break;
72+
default: ExampleUsage.print();
9373
}
94-
case "parse": {
95-
if (text == null || text.trim().isEmpty()) { ExampleUsage.print(); return; }
74+
break;
75+
}
76+
case "classify": {
77+
if (file == null && resource == null) { ExampleUsage.print(); return; }
78+
try (ImageRef image = Utils.createImageRef(file, resource)) {
9679
switch (subcommand) {
97-
case "mrz": MrzParserSnippet.run(text); break;
98-
case "barcode_doc": ParseBarcodeDocumentSnippet.run(text); break;
80+
case "document": DocumentClassifierSnippet.run(image); break;
9981
default: ExampleUsage.print();
10082
}
10183
break;
10284
}
103-
default: ExampleUsage.print();
10485
}
86+
case "parse": {
87+
if (text == null || text.trim().isEmpty()) { ExampleUsage.print(); return; }
88+
switch (subcommand) {
89+
case "mrz": MrzParserSnippet.run(text); break;
90+
case "barcode_doc": ParseBarcodeDocumentSnippet.run(text); break;
91+
default: ExampleUsage.print();
92+
}
93+
break;
94+
}
95+
default: ExampleUsage.print();
10596
}
10697

10798
// This demonstrates that no images remain in memory, after the ImageRef has been closed.

examples/java/src/main/java/io/scanbot/sdk/snippets/license/FloatingLicenseSnippet.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

examples/nodejs/src/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ async function main(): Promise<void> {
5454
const licenseInfo = await ScanbotSDK.getLicenseInfo();
5555
console.log("License Status:", licenseInfo.status);
5656

57-
const isFloatingLicense = !!licenseInfo.devices;
58-
if (isFloatingLicense) {
59-
console.log(
60-
`Using floating license with ${licenseInfo.devices} devices. Do not forget to call deregisterDevice ` +
61-
`when you no longer need the license.`
62-
);
63-
}
64-
6557
// `ScanbotSDK.autorelease` automatically disposes all unmanaged resources
6658
// (e.g. ImageRefs, scanners, results) created inside this block when it ends.
6759
// This prevents memory leaks and avoids having to call `.release()` manually.

examples/nodejs/src/snippets/license/floating-license.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)