steamutils 1.3.5 → 1.3.6
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 +39 -12
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -108,6 +108,7 @@ function SteamClient({
|
|
108
108
|
let lastTimePartySearch = 0
|
109
109
|
const appsPlayed = []
|
110
110
|
const ownedApps = []
|
111
|
+
let logOffEvent = null
|
111
112
|
|
112
113
|
const onAnyCallbacks = []
|
113
114
|
|
@@ -487,7 +488,10 @@ function SteamClient({
|
|
487
488
|
|
488
489
|
if (['ServiceUnavailable', 'NoConnection'].includes(msg) && autoReconnect && !isLogOff) {
|
489
490
|
async function relogin(retry) {
|
490
|
-
if (
|
491
|
+
if (isLogOff) {
|
492
|
+
console.error("Cannot relogin (logoff)")
|
493
|
+
return false
|
494
|
+
} else if (retry <= 0) {
|
491
495
|
console.error("Cannot relogin")
|
492
496
|
return false
|
493
497
|
} else {
|
@@ -500,21 +504,44 @@ function SteamClient({
|
|
500
504
|
console.log("Relogin success")
|
501
505
|
return true
|
502
506
|
} else {
|
503
|
-
await
|
507
|
+
const isLogOff = await new Promise((resolve, reject) => {
|
508
|
+
logOffEvent = resolve
|
509
|
+
setTimeout(resolve, 120000)
|
510
|
+
})
|
511
|
+
logOffEvent = null
|
512
|
+
if (isLogOff === true) {
|
513
|
+
return false
|
514
|
+
}
|
504
515
|
return await relogin(retry - 1)
|
505
516
|
}
|
506
517
|
} else {
|
507
|
-
await
|
518
|
+
const isLogOff = await new Promise((resolve, reject) => {
|
519
|
+
logOffEvent = resolve
|
520
|
+
setTimeout(resolve, 120000)
|
521
|
+
})
|
522
|
+
logOffEvent = null
|
523
|
+
if (isLogOff === true) {
|
524
|
+
return false
|
525
|
+
}
|
508
526
|
return await relogin(retry - 1)
|
509
527
|
}
|
510
528
|
}
|
511
529
|
}
|
512
530
|
|
513
|
-
await
|
514
|
-
|
515
|
-
|
531
|
+
const isLogOff = await new Promise((resolve, reject) => {
|
532
|
+
logOffEvent = resolve
|
533
|
+
setTimeout(resolve, 60000)
|
534
|
+
})
|
535
|
+
logOffEvent = null
|
536
|
+
if (isLogOff === true) {
|
516
537
|
offAllEvent()
|
517
538
|
doClearIntervals()
|
539
|
+
} else {
|
540
|
+
const isSuccess = await relogin(50)
|
541
|
+
if (!isSuccess) {
|
542
|
+
offAllEvent()
|
543
|
+
doClearIntervals()
|
544
|
+
}
|
518
545
|
}
|
519
546
|
} else {
|
520
547
|
offAllEvent()
|
@@ -1407,7 +1434,7 @@ function SteamClient({
|
|
1407
1434
|
|
1408
1435
|
async function logOff() {
|
1409
1436
|
isLogOff = true
|
1410
|
-
|
1437
|
+
logOffEvent?.(true)
|
1411
1438
|
steamClient.logOff()
|
1412
1439
|
}
|
1413
1440
|
|
@@ -1764,10 +1791,10 @@ function SteamClient({
|
|
1764
1791
|
return steamClient
|
1765
1792
|
},
|
1766
1793
|
getAccountInfoName,
|
1767
|
-
async getPlayersProfile(steamId, retry = 3){
|
1794
|
+
async getPlayersProfile(steamId, retry = 3) {
|
1768
1795
|
for (let i = 0; i < retry; i++) {
|
1769
1796
|
const profile = await getPlayersProfile(steamId)
|
1770
|
-
if(profile){
|
1797
|
+
if (profile) {
|
1771
1798
|
return profile
|
1772
1799
|
}
|
1773
1800
|
}
|
@@ -1873,13 +1900,13 @@ function SteamClient({
|
|
1873
1900
|
} catch (e) {
|
1874
1901
|
}
|
1875
1902
|
},
|
1876
|
-
getLastTimePartyRegister(){
|
1903
|
+
getLastTimePartyRegister() {
|
1877
1904
|
return lastTimePartyRegister
|
1878
1905
|
},
|
1879
|
-
getLastTimePartySearch(){
|
1906
|
+
getLastTimePartySearch() {
|
1880
1907
|
return lastTimePartySearch
|
1881
1908
|
},
|
1882
|
-
getLicenses(){
|
1909
|
+
getLicenses() {
|
1883
1910
|
return steamClient.licenses
|
1884
1911
|
const exampleLicenses = [{
|
1885
1912
|
package_id: 303386,
|