@bits-innovate/react-native-vstarcam 1.0.35 → 1.0.36

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
- // Clean up our reference to this SDK pointer
381
- for (ClientInfo info : clients.values()) {
382
- if (info.sdkClientPtr == sdkPtr) {
383
- Log.d(TAG, "SDK released client: " + info.deviceId + " (clearing sdkClientPtr)");
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);
@@ -570,11 +565,12 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
570
565
  params.putInt("state", 1); // CONNECTING
571
566
  sendEvent("onConnectionStateChanged", params);
572
567
 
573
- // Use realClientId for service param lookup (it has the correct prefix like VSTN)
574
- String realId = clientInfo.realClientId != null ? clientInfo.realClientId : clientInfo.deviceId;
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(realId);
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,20 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
592
588
  Log.d(TAG, "JNIApi.connect result: " + result);
593
589
 
594
590
  int res = (Integer) result;
595
- if (res != 0 && res != 1) {
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);
604
+ clientInfo.isConnected = true; // Optimistically set this if we got a handle
600
605
  } catch (java.lang.reflect.InvocationTargetException ite) {
601
606
  Log.e(TAG, "JNIApi.connect threw exception: " + ite.getCause(), ite.getCause());
602
607
  throw ite;
@@ -658,8 +663,13 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
658
663
  // result is likely boolean based on signature log
659
664
  if (result instanceof Boolean) {
660
665
  loginResult = (Boolean) result;
666
+ } else if (result instanceof Integer) {
667
+ int res = (Integer) result;
668
+ Log.d(TAG, "JNIApi.login integer result: " + res);
669
+ // If it's a handle or 0 (success), treat as true
670
+ loginResult = (res >= 0 || res < -2); // Permissive: only reject -1, -2 as common errors
661
671
  } else if (result != null) {
662
- loginResult = true; // Non-null result usually means success for some SDKs
672
+ loginResult = true; // Non-null result usually means success
663
673
  }
664
674
  } catch (java.lang.reflect.InvocationTargetException ite) {
665
675
  Throwable cause = ite.getCause();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -388,11 +388,11 @@ class VStarCamClient {
388
388
 
389
389
  // Wait for confirmation
390
390
  return new Promise((resolve) => {
391
- const timeout = setTimeout(() => resolve(false), 10000);
391
+ const waitTimeout = setTimeout(() => resolve(false), 10000);
392
392
 
393
393
  const handler: CommandEventListener = (_, cmd, data) => {
394
394
  if (cmd === 24593) {
395
- clearTimeout(timeout);
395
+ clearTimeout(waitTimeout);
396
396
  this.removeCommandListener(handler);
397
397
  const params = this.parseResponse(new TextDecoder().decode(data));
398
398
  resolve(params["result"] === "0");
@@ -411,7 +411,7 @@ class VStarCamClient {
411
411
  // The native module handles credentials and basic command sending.
412
412
  // It returns a promise that resolves with the device info and responsive: true.
413
413
  return await VStarCamModule.clientGetDeviceInfo(this.clientPtr);
414
- } catch (e) {
414
+ } catch (e: any) {
415
415
  console.error("[VStarCam] getDeviceInfo failed:", e);
416
416
  return null;
417
417
  }