Skip to content

Commit

Permalink
added initial version of mdns discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed May 19, 2023
1 parent 80223d1 commit 4d5c137
Show file tree
Hide file tree
Showing 4 changed files with 8,516 additions and 8,307 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.github.functionland:fula-build-aar:1.2.1' // From jitpack.io
implementation 'com.github.functionland:fula-build-aar:v1.6.0' // From jitpack.io
implementation 'com.github.functionland:wnfs-build-aar:v1.4.1' // From jitpack.io
implementation 'commons-io:commons-io:20030203.000550'
// implementation files('mobile.aar')
Expand Down
22 changes: 22 additions & 0 deletions android/src/main/java/land/fx/fula/FulaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,24 @@ private void checkFailedActions(boolean retry, int timeout, Promise promise) thr
}
}

@ReactMethod
public void listPeersFound(Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "listPeersFound started");
try {
string res = this.fula.listPeersFound();

//JSONArray jsonArray = new JSONArray(res);
String s = new String(res, StandardCharsets.UTF_8);
Log.d("ReactNative", "ls: res = " + s);
promise.resolve(s);
} catch (Exception e) {
Log.d("get", e.getMessage());
promise.reject(e);
}
});
}

private boolean retryFailedActionsInternal(int timeout) throws Exception {
try {
Log.d("ReactNative", "retryFailedActionsInternal started");
Expand Down Expand Up @@ -716,7 +734,11 @@ public void writeFile(String fulaTargetFilename, String localFilename, Promise p
this.rootConfig = config;
this.encrypt_and_store_config();
if (this.fula != null) {
Log.d("ReactNative", "writeFile flsuhing");
this.fula.flush();
Log.d("ReactNative", "writeFile flsuhed");
} else {
Log.d("ReactNative", "writeFile Error: fula is null");
}
promise.resolve(config.getCid());
} else {
Expand Down
3 changes: 2 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const App = () => {
203, 243, 211, 78, 120, 114, 199, 1, 197, 134, 6, 91, 87, 152,
];
const privateKeyString = "\\test";
const bloxAddr = '/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835/p2p-circuit/p2p/12D3KooWD69C5yX91nPe3tz6HRiuw7Pia4xsxE9xv2CghoyK6MPK';
//const bloxAddr = '/dns/relay.dev.fx.land/tcp/4001/p2p/12D3KooWDRrBaAfPwsGJivBoUw5fE7ZpDiyfUjqgiURq2DEcL835/p2p-circuit/p2p/12D3KooWD69C5yX91nPe3tz6HRiuw7Pia4xsxE9xv2CghoyK6MPK';
const bloxAddr = '/ip4/192.168.2.14/tcp/40001/p2p/12D3KooWD69C5yX91nPe3tz6HRiuw7Pia4xsxE9xv2CghoyK6MPK';
const newClient = async () => {
try {
return fula.newClient(
Expand Down
Loading

0 comments on commit 4d5c137

Please sign in to comment.