@bits-innovate/react-native-vstarcam 1.0.35 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -377,15 +377,10 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
377
377
|
final long sdkPtr = (Long) args[0];
|
|
378
378
|
Log.d(TAG, "Release callback: sdkPtr=" + sdkPtr);
|
|
379
379
|
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
info.sdkClientPtr = 0;
|
|
385
|
-
info.isConnected = false;
|
|
386
|
-
info.isLoggedIn = false;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
380
|
+
// info.sdkClientPtr = 0
|
|
381
|
+
// NOTE: In 1.0.35 we cleared the pointer here, but it caused "Client not connected"
|
|
382
|
+
// because the SDK seems to call this on various events, not just destruction.
|
|
383
|
+
// We will only clear it on explicit disconnect/destroy.
|
|
389
384
|
}
|
|
390
385
|
} catch (Exception e) {
|
|
391
386
|
Log.e(TAG, "Error in releaseListener callback", e);
|
|
@@ -422,7 +417,7 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
422
417
|
sendEvent("onConnectionStateChanged", params);
|
|
423
418
|
|
|
424
419
|
// Update connected state
|
|
425
|
-
entry.getValue().isConnected = (state ==
|
|
420
|
+
entry.getValue().isConnected = (state == 2); // ONLINE is 2 in native, 3 in JS (now aligned to 2 in index.ts)
|
|
426
421
|
break;
|
|
427
422
|
}
|
|
428
423
|
}
|
|
@@ -570,11 +565,12 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
570
565
|
params.putInt("state", 1); // CONNECTING
|
|
571
566
|
sendEvent("onConnectionStateChanged", params);
|
|
572
567
|
|
|
573
|
-
//
|
|
574
|
-
|
|
568
|
+
// CRITICAL: For virtual UIDs (like ACAE...), always use the ORIGINAL device ID
|
|
569
|
+
// to look up service parameters. Even if it's converted to a VSTJ/VSTN real ID,
|
|
570
|
+
// it often must connect via the specific vstarcam2018/2019 servers matched to its prefix.
|
|
575
571
|
String param = (serverParam != null && !serverParam.isEmpty())
|
|
576
572
|
? serverParam
|
|
577
|
-
: getServiceParam(
|
|
573
|
+
: getServiceParam(clientInfo.deviceId);
|
|
578
574
|
|
|
579
575
|
// Default connectType to 126 (from V1 app) if not specified
|
|
580
576
|
// connectType 126 = P2P/Relay combination that works reliably
|
|
@@ -592,11 +588,19 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
592
588
|
Log.d(TAG, "JNIApi.connect result: " + result);
|
|
593
589
|
|
|
594
590
|
int res = (Integer) result;
|
|
595
|
-
|
|
591
|
+
Log.d(TAG, "JNIApi.connect result: " + res);
|
|
592
|
+
|
|
593
|
+
// CRITICAL: In some P2P SDKs, handles can be negative (like pointers).
|
|
594
|
+
// We also saw '7' as a successful handle.
|
|
595
|
+
// We will only reject if it's a specific known error code (usually -1 or -2, but we'll be permissive).
|
|
596
|
+
if (res == -1) {
|
|
596
597
|
Log.w(TAG, "JNIApi.connect failed with code: " + res);
|
|
597
598
|
promise.reject("CONNECT_FAILED", "SDK connect error code: " + res);
|
|
598
599
|
return;
|
|
599
600
|
}
|
|
601
|
+
|
|
602
|
+
// Code >= 0 or other negative values might be a success (Session ID or State)
|
|
603
|
+
Log.d(TAG, "JNIApi.connect successful or handle returned: " + res);
|
|
600
604
|
} catch (java.lang.reflect.InvocationTargetException ite) {
|
|
601
605
|
Log.e(TAG, "JNIApi.connect threw exception: " + ite.getCause(), ite.getCause());
|
|
602
606
|
throw ite;
|
|
@@ -658,8 +662,13 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
658
662
|
// result is likely boolean based on signature log
|
|
659
663
|
if (result instanceof Boolean) {
|
|
660
664
|
loginResult = (Boolean) result;
|
|
665
|
+
} else if (result instanceof Integer) {
|
|
666
|
+
int res = (Integer) result;
|
|
667
|
+
Log.d(TAG, "JNIApi.login integer result: " + res);
|
|
668
|
+
// If it's a handle or 0 (success), treat as true
|
|
669
|
+
loginResult = (res >= 0 || res < -2); // Permissive: only reject -1, -2 as common errors
|
|
661
670
|
} else if (result != null) {
|
|
662
|
-
loginResult = true; // Non-null result usually means success
|
|
671
|
+
loginResult = true; // Non-null result usually means success
|
|
663
672
|
}
|
|
664
673
|
} catch (java.lang.reflect.InvocationTargetException ite) {
|
|
665
674
|
Throwable cause = ite.getCause();
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -95,18 +95,17 @@ const VStarCamModule = NativeModules.VStarCam
|
|
|
95
95
|
|
|
96
96
|
// Connection states
|
|
97
97
|
export enum ConnectionState {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
REMOVE_CLOSE = 11,
|
|
98
|
+
CONNECTING = 0,
|
|
99
|
+
INITIALIZING = 1,
|
|
100
|
+
ONLINE = 2,
|
|
101
|
+
CONNECT_FAILED = 3,
|
|
102
|
+
DISCONNECTED = 4,
|
|
103
|
+
INVALID_ID = 5,
|
|
104
|
+
OFFLINE = 6,
|
|
105
|
+
TIMEOUT = 7,
|
|
106
|
+
WRONG_PWD = 8,
|
|
107
|
+
INVALID_CLIENT = 9,
|
|
108
|
+
MAX_SESSION = 10,
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
// Connection modes
|
|
@@ -388,11 +387,11 @@ class VStarCamClient {
|
|
|
388
387
|
|
|
389
388
|
// Wait for confirmation
|
|
390
389
|
return new Promise((resolve) => {
|
|
391
|
-
const
|
|
390
|
+
const waitTimeout = setTimeout(() => resolve(false), 10000);
|
|
392
391
|
|
|
393
392
|
const handler: CommandEventListener = (_, cmd, data) => {
|
|
394
393
|
if (cmd === 24593) {
|
|
395
|
-
clearTimeout(
|
|
394
|
+
clearTimeout(waitTimeout);
|
|
396
395
|
this.removeCommandListener(handler);
|
|
397
396
|
const params = this.parseResponse(new TextDecoder().decode(data));
|
|
398
397
|
resolve(params["result"] === "0");
|
|
@@ -411,7 +410,7 @@ class VStarCamClient {
|
|
|
411
410
|
// The native module handles credentials and basic command sending.
|
|
412
411
|
// It returns a promise that resolves with the device info and responsive: true.
|
|
413
412
|
return await VStarCamModule.clientGetDeviceInfo(this.clientPtr);
|
|
414
|
-
} catch (e) {
|
|
413
|
+
} catch (e: any) {
|
|
415
414
|
console.error("[VStarCam] getDeviceInfo failed:", e);
|
|
416
415
|
return null;
|
|
417
416
|
}
|