use session.poll as well for polling when receiving a message
This commit is contained in:
parent
9610e9b57e
commit
20c3023b94
3 changed files with 14 additions and 19 deletions
|
@ -202,13 +202,12 @@ module.exports = class RiotSession {
|
|||
return this.browser.close();
|
||||
}
|
||||
|
||||
async poll(callback, timeout) {
|
||||
const INTERVAL = 100;
|
||||
async poll(callback, timeout, interval = 100) {
|
||||
let waited = 0;
|
||||
while(waited < timeout) {
|
||||
await this.delay(INTERVAL);
|
||||
waited += INTERVAL;
|
||||
if (callback()) {
|
||||
await this.delay(interval);
|
||||
waited += interval;
|
||||
if (await callback()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue