Jump to content
McKay Development

E46

Member
  • Content Count

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Might be an issue with my code actually. This is what I've got currently as start/stop function: function startBot(steamUsername, steamPassword) { if(typeof activeBots[steamUsername] !== 'undefined' && activeBots[steamUsername]) { stopBot(steamUsername); } activeBots[steamUsername] = createBot(steamUsername, steamPassword); activeBots[steamUsername].steamLogin(); } function stopBot(steamUsername) { if(typeof activeBots[steamUsername] !== 'undefined' && activeBots[steamUsername]) { activeBots[steamUsername].logOff(); // logout delete activeBots[steamUsername]; // clear memory? log('bot stopped', steamUsername); } } When I run a test like this, it always seem to leave the SteamUser class in memory forever, Even though they exit with error 34: async function runTest1() { startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account1', ''); startBot('account2', ''); startBot('account3', ''); await sleep(30000); stopBot('account1'); stopBot('account2'); stopBot('account3'); await sleep(200000); }
  2. Hello, What is the proper way to remove/clear a steamUser class from memory after it has run into the error event? If the logOn(); was successful and I call the logOff() and then delete the var it seems to get cleared properly or picked up by the GC at least. with an error this doesn't seem the case and hangs around in the memory forever. (tested with --inspect) (I know delete might not work if it is referenced somewhere else but its not. Also I understand that it won't get cleared instantly but might be picked up by the garbage collector correct? but even after leaving it idle for a long time afterwards with no running bots the steamUser in the memory never gets cleared) Or am I doing something obviously wrong in the code? Any help would be appreciated. SteamUser: 4.13.2 NodeJS: v12.16.1 const SteamUser = require('steam-user'); var activeBots = {}; var botOptions = { promptSteamGuardCode: false, singleSentryfile: false, autoRelogin: true, //localAddress: '', dataDirectory: null, }; function createBot(steamUsername, steamPassword) { var bot = new SteamUser(botOptions); /* * Bot Functions */ bot.steamLogin = function () { bot.logOn({ 'accountName': steamUsername, 'password': steamPassword, }); } /* * Bot Events */ bot.on('loggedOn', function(details) { log('loggedOn successful', steamUsername); bot.gamesPlayed([730]); // csgo log('loggedOn gamesPlayed successful', steamUsername); }); bot.on('error', function(err) { switch(err.eresult) { case 5: log('error: invalid password'); case 84: log('error: rate limit exceeded'); case 6: log('error: logged in elsewhere'); default: log('error: ' + err.eresult, steamUsername); } // stop bot on any error stopBot(steamUsername); }); return bot; } function startBot(steamUsername, steamPassword) { activeBots[steamUsername] = createBot(steamUsername, steamPassword); activeBots[steamUsername].steamLogin(); } function stopBot(steamUsername) { if(typeof activeBots[steamUsername] !== 'undefined' && activeBots[steamUsername]) { //await activeBots[steamUsername].logOff(); // logOff is not async function? activeBots[steamUsername].logOff(); // logout, but if the bot ran into an error its not logged in delete activeBots[steamUsername]; // seems to work, but not if it ran into an error log('bot stopped', steamUsername); } } /* * Logging */ function log(message, steamUsername = false) { if (steamUsername) { console.log('[' + steamUsername + '] ' + message); } else { console.log(message); } } // testing runTest1(); async function runTest1() { startBot('', ''); await sleep(5000); stopBot(''); await sleep(200000); } function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); } console.log('end of file');
×
×
  • Create New...