steamutils 1.4.66 → 1.4.69
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +49 -54
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -2046,34 +2046,27 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2046
2046
|
}
|
2047
2047
|
}
|
2048
2048
|
|
2049
|
-
async function reLogin(retry =
|
2050
|
-
|
2051
|
-
offAllEvent();
|
2052
|
-
doClearIntervals();
|
2049
|
+
async function reLogin(retry = 0) {
|
2050
|
+
const MAX_RETRY = 1000;
|
2053
2051
|
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2052
|
+
while (++retry < MAX_RETRY) {
|
2053
|
+
if (isLogOff || retry > MAX_RETRY) {
|
2054
|
+
offAllEvent();
|
2055
|
+
doClearIntervals();
|
2057
2056
|
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
return true;
|
2062
|
-
}
|
2057
|
+
error(`Cannot relogin (${isLogOff ? "logoff" : "retry limit reached"})`);
|
2058
|
+
return false;
|
2059
|
+
}
|
2063
2060
|
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
}
|
2061
|
+
const isSuccess = await login(true);
|
2062
|
+
if (isSuccess) {
|
2063
|
+
log("Relogin success");
|
2064
|
+
return true;
|
2065
|
+
}
|
2070
2066
|
|
2071
|
-
|
2072
|
-
await sleep(60000);
|
2073
|
-
return await reLogin(retry - 1);
|
2074
|
-
} else {
|
2075
|
-
return false;
|
2067
|
+
await sleep(15000);
|
2076
2068
|
}
|
2069
|
+
return false;
|
2077
2070
|
}
|
2078
2071
|
|
2079
2072
|
async function login(reconnect = false) {
|
@@ -2131,49 +2124,51 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2131
2124
|
clearTimeout(_cleanNodeSteamFriendTimeout);
|
2132
2125
|
}
|
2133
2126
|
|
2134
|
-
steamClient
|
2135
|
-
|
2127
|
+
if (steamClient) {
|
2128
|
+
steamClient.logOff();
|
2129
|
+
await sleep(5000);
|
2136
2130
|
|
2137
|
-
|
2131
|
+
steamClient._connection?.end(true);
|
2138
2132
|
|
2139
|
-
|
2140
|
-
|
2133
|
+
function cleanSteamClient(obj, key) {
|
2134
|
+
const value = obj[key];
|
2141
2135
|
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2136
|
+
try {
|
2137
|
+
delete obj[key];
|
2138
|
+
} catch (e) {
|
2139
|
+
return;
|
2140
|
+
}
|
2147
2141
|
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2142
|
+
if (!value) {
|
2143
|
+
return;
|
2144
|
+
}
|
2151
2145
|
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2146
|
+
if (typeof value !== "object") {
|
2147
|
+
return;
|
2148
|
+
}
|
2155
2149
|
|
2156
|
-
|
2157
|
-
|
2158
|
-
} else {
|
2159
|
-
const constructorName = Object.getPrototypeOf(value)?.constructor?.name;
|
2160
|
-
if (constructorName === "TLSSocket") {
|
2161
|
-
value.destroy?.();
|
2162
|
-
} else if (constructorName === "Timeout") {
|
2163
|
-
clearTimeout(value);
|
2164
|
-
} else if (constructorName === "SteamUser") {
|
2150
|
+
if (Array.isArray(value)) {
|
2151
|
+
value.length = 0;
|
2165
2152
|
} else {
|
2166
|
-
|
2167
|
-
|
2153
|
+
const constructorName = Object.getPrototypeOf(value)?.constructor?.name;
|
2154
|
+
if (constructorName === "TLSSocket") {
|
2155
|
+
value.destroy?.();
|
2156
|
+
} else if (constructorName === "Timeout") {
|
2157
|
+
clearTimeout(value);
|
2158
|
+
} else if (constructorName === "SteamUser") {
|
2159
|
+
} else {
|
2160
|
+
for (const valuekey in value) {
|
2161
|
+
cleanSteamClient(value, valuekey);
|
2162
|
+
}
|
2168
2163
|
}
|
2169
2164
|
}
|
2170
2165
|
}
|
2171
|
-
}
|
2172
2166
|
|
2173
|
-
|
2174
|
-
|
2167
|
+
for (const key in steamClient) {
|
2168
|
+
cleanSteamClient(steamClient, key);
|
2169
|
+
}
|
2170
|
+
steamClient = null;
|
2175
2171
|
}
|
2176
|
-
steamClient = null;
|
2177
2172
|
}
|
2178
2173
|
|
2179
2174
|
async function init() {
|