@functionland/react-native-fula 1.1.6 → 1.1.8
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.
|
@@ -164,12 +164,16 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
164
164
|
if (this.fula != null) {
|
|
165
165
|
try {
|
|
166
166
|
boolean connectionStatus = this.checkConnectionInternal(timeout);
|
|
167
|
+
Log.d("ReactNative", "checkConnection ended " + connectionStatus);
|
|
167
168
|
promise.resolve(connectionStatus);
|
|
168
169
|
}
|
|
169
170
|
catch (Exception e) {
|
|
170
171
|
Log.d("ReactNative", "checkConnection failed with Error: " + e.getMessage());
|
|
171
172
|
promise.resolve(false);
|
|
172
173
|
}
|
|
174
|
+
} else {
|
|
175
|
+
Log.d("ReactNative", "checkConnection failed with Error: " + "fula is null");
|
|
176
|
+
promise.resolve(false);
|
|
173
177
|
}
|
|
174
178
|
});
|
|
175
179
|
}
|
|
@@ -179,12 +183,13 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
179
183
|
Log.d("ReactNative", "newClient started");
|
|
180
184
|
ThreadUtils.runOnExecutor(() -> {
|
|
181
185
|
try {
|
|
182
|
-
Log.d("ReactNative", "newClient storePath= " + storePath);
|
|
186
|
+
Log.d("ReactNative", "newClient storePath= " + storePath + " bloxAddr= " + bloxAddr + " exchange= " + exchange + " autoFlush= " + autoFlush + " useRelay= " + useRelay + " refresh= " + refresh);
|
|
183
187
|
byte[] identity = toByte(identityString);
|
|
184
188
|
Log.d("ReactNative", "newClient identity= " + identityString);
|
|
185
189
|
this.newClientInternal(identity, storePath, bloxAddr, exchange, autoFlush, useRelay, refresh);
|
|
186
190
|
//String objString = Arrays.toString(obj);
|
|
187
191
|
String peerId = this.fula.id();
|
|
192
|
+
Log.d("ReactNative", "newClient peerId= " + peerId);
|
|
188
193
|
promise.resolve(peerId);
|
|
189
194
|
} catch (Exception e) {
|
|
190
195
|
Log.d("ReactNative", "newClient failed with Error: " + e.getMessage());
|
|
@@ -203,8 +208,10 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
203
208
|
if (filesystemCheck) {
|
|
204
209
|
if (this.client != null && this.rootConfig != null && !this.rootConfig.getCid().isEmpty()) {
|
|
205
210
|
initialized = true;
|
|
211
|
+
Log.d("ReactNative", "isReady is true with filesystem check");
|
|
206
212
|
}
|
|
207
213
|
} else {
|
|
214
|
+
Log.d("ReactNative", "isReady is true without filesystem check");
|
|
208
215
|
initialized = true;
|
|
209
216
|
}
|
|
210
217
|
}
|
|
@@ -267,6 +274,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
267
274
|
try {
|
|
268
275
|
this.fula.connectToBlox();
|
|
269
276
|
connectionStatus.set(true);
|
|
277
|
+
Log.d("ReactNative", "checkConnectionInternal succeeded ");
|
|
270
278
|
} catch (Exception e) {
|
|
271
279
|
Log.d("ReactNative", "checkConnectionInternal failed with Error: " + e.getMessage());
|
|
272
280
|
}
|
|
@@ -502,7 +510,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
502
510
|
} else {
|
|
503
511
|
fulaConfig.setStorePath(storePath);
|
|
504
512
|
}
|
|
505
|
-
Log.d("ReactNative", "storePath is set: " + fulaConfig.getStorePath());
|
|
513
|
+
Log.d("ReactNative", "newClientInternal storePath is set: " + fulaConfig.getStorePath());
|
|
506
514
|
|
|
507
515
|
byte[] peerIdentity = this.createPeerIdentity(identity);
|
|
508
516
|
fulaConfig.setIdentity(peerIdentity);
|
|
@@ -517,6 +525,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
517
525
|
}
|
|
518
526
|
if (this.fula == null || refresh) {
|
|
519
527
|
Log.d("ReactNative", "Creating a new Fula instance");
|
|
528
|
+
shutdownInternal();
|
|
520
529
|
this.fula = Fulamobile.newClient(fulaConfig);
|
|
521
530
|
}
|
|
522
531
|
if (this.fula != null) {
|
|
@@ -994,20 +1003,23 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
994
1003
|
});
|
|
995
1004
|
}
|
|
996
1005
|
|
|
1006
|
+
private void shutdownInternal() throws Exception {
|
|
1007
|
+
try {
|
|
1008
|
+
if(this.fula != null) {
|
|
1009
|
+
this.fula.shutdown();
|
|
1010
|
+
this.fula = null;
|
|
1011
|
+
this.client = null;
|
|
1012
|
+
}
|
|
1013
|
+
} catch (Exception e) {
|
|
1014
|
+
Log.d("ReactNative", "shutdownInternal"+ e.getMessage());
|
|
1015
|
+
throw (e);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
997
1019
|
@ReactMethod
|
|
998
1020
|
public void shutdown(Promise promise) {
|
|
999
1021
|
ThreadUtils.runOnExecutor(() -> {
|
|
1000
|
-
|
|
1001
|
-
if(this.fula != null) {
|
|
1002
|
-
this.fula.shutdown();
|
|
1003
|
-
this.fula = null;
|
|
1004
|
-
this.client = null;
|
|
1005
|
-
}
|
|
1006
|
-
promise.resolve(true);
|
|
1007
|
-
} catch (Exception e) {
|
|
1008
|
-
promise.reject(e);
|
|
1009
|
-
Log.d("ReactNative", "shutdown"+ e.getMessage());
|
|
1010
|
-
}
|
|
1022
|
+
shutdownInternal();
|
|
1011
1023
|
});
|
|
1012
1024
|
}
|
|
1013
1025
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionland/react-native-fula",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|