use session.poll as well for polling when receiving a message

This commit is contained in:
Bruno Windels 2019-04-16 11:55:33 +02:00
parent 9610e9b57e
commit 20c3023b94
3 changed files with 14 additions and 19 deletions

View file

@ -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;
}
}