steamutils 1.2.9 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SteamClient.js +22 -14
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -373,34 +373,42 @@ function SteamClient({
|
|
373
373
|
steamClient.on('disconnected', async (eresult, msg) => {
|
374
374
|
state = 'Offline'
|
375
375
|
log('disconnected', eresult, msg)
|
376
|
-
|
376
|
+
|
377
377
|
callEvent(events.disconnected, {eresult, msg})
|
378
378
|
|
379
379
|
if (eresult === 3 && autoReconnect && !isLogOff) {
|
380
|
-
|
381
380
|
async function relogin(retry) {
|
382
381
|
if (retry <= 0) {
|
383
382
|
console.error("Cannot relogin")
|
384
|
-
return
|
385
|
-
}
|
386
|
-
|
387
|
-
|
388
|
-
|
383
|
+
return false
|
384
|
+
} else {
|
385
|
+
const isSuccess = await login(true)
|
386
|
+
if (isSuccess) {
|
387
|
+
const loggedOnResponse = await new Promise(resolve => {
|
388
|
+
onEvent('loggedOn', function (loggedOnResponse) {
|
389
|
+
resolve(loggedOnResponse)
|
390
|
+
}, true, 120000)
|
391
|
+
})
|
389
392
|
if (loggedOnResponse) {
|
390
393
|
console.log("Relogin success")
|
394
|
+
return true
|
391
395
|
} else {
|
392
|
-
relogin(retry - 1)
|
396
|
+
return await relogin(retry - 1)
|
393
397
|
}
|
394
|
-
}
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
}, 60000)
|
398
|
+
} else {
|
399
|
+
await sleep(60000)
|
400
|
+
return await relogin(retry - 1)
|
401
|
+
}
|
399
402
|
}
|
400
403
|
}
|
401
404
|
|
402
405
|
await sleep(60000)
|
403
|
-
await relogin(10)
|
406
|
+
const isSuccess = await relogin(10)
|
407
|
+
if (!isSuccess) {
|
408
|
+
doClearIntervals()
|
409
|
+
}
|
410
|
+
} else {
|
411
|
+
doClearIntervals()
|
404
412
|
}
|
405
413
|
})
|
406
414
|
steamClient.on('error', async (e) => {
|