diff --git a/README.md b/README.md index 3491e8f..edccd98 100644 --- a/README.md +++ b/README.md @@ -255,10 +255,11 @@ export const defaultConfig = { ### [`NodeDiscoverer`](src/internal/node/discoverer/node-discoverer.android.ts) -| Function | Return type | Description | -|---------------------------------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------| -| `getLocalNode()` | `Promise` | Get a reference to the local node (smartphone). | -| `getConnectedNodes(timeout: number = 5000)` | `Promise` | Get a reference to the local node (smartphone). | +| `areConnectedNodes()` | `Promise` | Returns true if there are connected nodes. | +| `getConnectedNodes(timeout: number = 5000)` | `Promise { + const connectedNodes = this.nodeClient.getConnectedNodes(); + return new Promise((resolve) => { + connectedNodes.addOnCompleteListener(new OnCompleteListener({ + onComplete: task => { + if (!task.isSuccessful()) { + return resolve(false); + } + + const nodes = task.getResult(); + resolve(nodes.size() !== 0); + } + })); + }); + } + public getConnectedNodes(timeout: number = 5000): Promise { return firstValueFrom( this.scanConnectedNodes(timeout) diff --git a/src/internal/node/discoverer/node-discoverer.ts b/src/internal/node/discoverer/node-discoverer.ts index cdfdcee..ff94da0 100644 --- a/src/internal/node/discoverer/node-discoverer.ts +++ b/src/internal/node/discoverer/node-discoverer.ts @@ -2,6 +2,7 @@ import { Node } from "../index"; export interface NodeDiscoverer { getLocalNode(): Promise; + areConnectedNodes(): Promise; getConnectedNodes(timeout?: number): Promise; }