steamutils 1.4.88 → 1.4.89

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 -8
  2. package/package.json +1 -1
package/SteamClient.js CHANGED
@@ -2159,7 +2159,7 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
2159
2159
  log("logOff");
2160
2160
  isLogOff = true;
2161
2161
 
2162
- MessageQueue.length = 0;
2162
+ clearMessageQueue();
2163
2163
 
2164
2164
  callEvent(events.logOff);
2165
2165
  events.logOff = [];
@@ -2295,8 +2295,16 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
2295
2295
 
2296
2296
  const MessageQueue = [];
2297
2297
 
2298
+ function clearMessageQueue() {
2299
+ while (MessageQueue.length) {
2300
+ const item = MessageQueue.shift();
2301
+ item?.callback?.();
2302
+ }
2303
+ }
2304
+
2298
2305
  async function _execMessageQueue() {
2299
2306
  if (isLogOff) {
2307
+ clearMessageQueue();
2300
2308
  return;
2301
2309
  }
2302
2310
 
@@ -2304,13 +2312,19 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
2304
2312
  return;
2305
2313
  }
2306
2314
  while (MessageQueue.length) {
2307
- isSendingFriendMessages = true;
2308
- const item = MessageQueue.shift();
2309
- const result = await _sendFriendMessage(item.steamId, item.message);
2310
- item.callback(result);
2311
- if (MessageQueue.length) {
2312
- await sleep(1000);
2313
- }
2315
+ try {
2316
+ isSendingFriendMessages = true;
2317
+ const item = MessageQueue.shift();
2318
+ const result = await _sendFriendMessage(item.steamId, item.message);
2319
+ if (typeof item.callback === "function") {
2320
+ try {
2321
+ await item.callback(result);
2322
+ } catch (e) {}
2323
+ }
2324
+ if (MessageQueue.length) {
2325
+ await sleep(1000);
2326
+ }
2327
+ } catch (e) {}
2314
2328
  }
2315
2329
  isSendingFriendMessages = false;
2316
2330
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.4.88",
3
+ "version": "1.4.89",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",