steamutils 1.1.97 → 1.1.98

Sign up to get free protection for your applications and to get access to all the features.
package/SteamClient.js CHANGED
@@ -87,10 +87,12 @@ function SteamClient({
87
87
  isPartyRegister = true,
88
88
  autoPlay = false,
89
89
  autoAcceptTradeRequest = false,
90
+ autoReconnect = true,
90
91
  }) {
91
92
  const steamClient = new SteamUser()
92
93
  let prime = null
93
94
  let state = 'Offline'//InGame, Online
95
+ let isLogOff = false
94
96
 
95
97
  const events = {
96
98
  user: [],
@@ -372,6 +374,12 @@ function SteamClient({
372
374
  log('disconnected', eresult, msg)
373
375
  doClearIntervals()
374
376
  callEvent(events.disconnected, {eresult, msg})
377
+
378
+ if (eresult === 3 && autoReconnect && !isLogOff) {
379
+ setTimeout(function () {
380
+ login(true)
381
+ }, 30000)
382
+ }
375
383
  })
376
384
  steamClient.on('error', async (e) => {
377
385
  let errorStr = ``
@@ -1040,21 +1048,28 @@ function SteamClient({
1040
1048
  }
1041
1049
  }
1042
1050
 
1043
- async function login() {
1051
+ async function login(reconnect = false) {
1044
1052
  if (cookie) {
1045
- log('login with cookie')
1053
+ log(reconnect ? 'reconnect with cookie' : 'login with cookie')
1046
1054
  const newCookie = await loginWithCookie(cookie)
1047
1055
  if (newCookie) {
1048
1056
  cookie = newCookie
1049
1057
  }
1050
1058
  } else if (username && password) {
1051
- log(`login with username ${username}`)
1059
+ log(reconnect ? `reconnect with username ${username}` : `login with username ${username}`)
1052
1060
  steamClient.logOn({
1053
1061
  accountName: username, password: password, rememberPassword: true, machineName: 'Natri',
1054
1062
  })
1055
1063
  }
1056
1064
  }
1057
1065
 
1066
+ async function logOff() {
1067
+ isLogOff = true
1068
+ offAllEvent()
1069
+ doClearIntervals()
1070
+ steamClient.logOff()
1071
+ }
1072
+
1058
1073
  function onCookie(callback) {
1059
1074
  if(getCookies() ){
1060
1075
  callback(getCookies())
@@ -1286,7 +1301,8 @@ function SteamClient({
1286
1301
  isPrime(){
1287
1302
  return prime === true
1288
1303
  },
1289
- getFriendList
1304
+ getFriendList,
1305
+ logOff,
1290
1306
  }
1291
1307
  }
1292
1308
 
package/index.js CHANGED
@@ -3244,7 +3244,7 @@ class SteamUser {
3244
3244
  FriendsPreviously: [],//Friends who have played Counter-Strike: Global Offensive previously _
3245
3245
  FriendsAddedLibrary: [],//Friends who have Counter-Strike: Global Offensive in their library _
3246
3246
  }
3247
- if (!result.data) {
3247
+ if (!result?.data) {
3248
3248
  return data
3249
3249
  }
3250
3250
  const $ = result._$()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.1.97",
3
+ "version": "1.1.98",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",