steamutils 1.2.9 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/SteamClient.js +22 -14
  2. 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
- doClearIntervals()
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
- const isSuccess = await login(true)
387
- if (isSuccess) {
388
- onEvent('loggedOn', function (loggedOnResponse) {
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
- }, true, 120000)
395
- } else {
396
- setTimeout(function () {
397
- relogin(retry - 1)
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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.2.09",
3
+ "version": "1.2.10",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",