Xaviius Posted October 1, 2020 Report Posted October 1, 2020 Hey, is there any possibility to repeat the requestLiveGameForUser method? If I call the method the first time it works, but the second, third... time it does not. Here is the important code: csgoUser.on('connectedToGC', async () => { searchedids = [] for (let steamid of steamids) { if (!searchedids.some((searched) => searched === steamid.getSteamID64())) { csgoUser.requestLiveGameForUser(steamid.getSteamID64()); await sleep(10000) } } }); csgoUser.on('matchList', async (response) => { console.log(response); steamClient.logOff(); }); Any clue why it does not work? Thank you for this awesome lib! Quote
Dr. McKay Posted October 2, 2020 Report Posted October 2, 2020 Well, it looks like you're logging off in your matchList callback, and if you aren't logged on you can't talk to the GC. Xaviius 1 Quote
Xaviius Posted October 2, 2020 Author Report Posted October 2, 2020 @Dr. McKay Yeah well there was the error. Thank you! Is there any way to await requestLiveGameForUser event? So I don't have to use: await sleep(10000) Thank you! Quote
Dr. McKay Posted October 3, 2020 Report Posted October 3, 2020 16 hours ago, Xaviius said: Is there any way to await requestLiveGameForUser event? You could create a global promise, await it, and resolve it in the matchList event. Quote
Xaviius Posted October 3, 2020 Author Report Posted October 3, 2020 I already tried to use it with Promise like this: await new Promise((resolve) => { csgoUser.on('matchList', resolve); }) The first time it works and the second it awaits and never finishes... the whole important code looks like this at the moment: for (let steamid of steamids) { if (!searchedids.some((searched) => searched === steamid.getSteamID64())) { csgoUser.requestLiveGameForUser(steamid.getSteamID64()); await matchList(await new Promise((resolve) => { csgoUser.on('matchList', resolve); })); await sleep(1000); } } steamClient.logOff(); Quote
Dr. McKay Posted October 3, 2020 Report Posted October 3, 2020 You probably want to replace that .on() call with .once() so you don't leak event listeners. Also what is your matchList() function doing? Quote
Xaviius Posted October 3, 2020 Author Report Posted October 3, 2020 Its basically what I did in the event before: async function matchList(matches: Array<IMatch>) { console.log(matches) if (matches[0]) { matches[0].roundstats_legacy.reservation.account_ids.forEach(async (accid: number) => { if (await monitoringRepository.findOne(SteamID.fromIndividualAccountID(accid).getSteamID64()) === undefined && await mmRepository.findOne(SteamID.fromIndividualAccountID(accid).getSteamID64()) === undefined) { var steamid_db = { id: SteamID.fromIndividualAccountID(accid).getSteamID64(), date: new Date().toJSON().slice(0, 10) }; searchedids.push(SteamID.fromIndividualAccountID(accid).getSteamID64()); mmRepository.save(steamid_db).then(() => logger.info("SteamID: " + SteamID.fromIndividualAccountID(accid).getSteamID64() + " added to matchmaking accounts.")) .catch((err) => logger.error(err)); } }); } } Even with once it does not work constantly. Sometimes it only works for 2 steamids and then again only for one, even though they are 8. steamids is an array of type SteamID of your other library. Quote
Dr. McKay Posted October 3, 2020 Report Posted October 3, 2020 It could be just that the GC has some rate limiting. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.