mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
allow providing a timeout in milliseconds when fetching get self info
This commit is contained in:
parent
41d607a92f
commit
6469b815b1
2 changed files with 14 additions and 3 deletions
|
|
@ -345,7 +345,7 @@ class Connection extends EventEmitter {
|
|||
});
|
||||
}
|
||||
|
||||
getSelfInfo() {
|
||||
getSelfInfo(timeoutMillis = null) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
|
||||
// listen for response
|
||||
|
|
@ -353,7 +353,10 @@ class Connection extends EventEmitter {
|
|||
resolve(selfInfo);
|
||||
});
|
||||
|
||||
// todo add timeout in case user connected to unsupported device
|
||||
// timeout after provided milliseconds if device did not respond
|
||||
if(timeoutMillis != null){
|
||||
setTimeout(reject, timeoutMillis);
|
||||
}
|
||||
|
||||
// request self info
|
||||
await this.sendCommandAppStart();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue