Jump to content


Photo
Question

Question about double console.log line

node.js node-steam-user

  • Please log in to reply
3 replies to this topic

#1 Skyper

Skyper

    Newbie

  • Member
  • Pip
  • 9 posts

Posted 04 January 2019 - 05:32 AM

Hello, sorry for stupid post but I have question why after use this code second time console.log print the same information twice?

3 turns on 3 times when I use in other place 'loggedOn' I see again console.log(this.informations) in other function. Someone can tell me why and what I can to do with that? 

Sorry for my rip English and code. 

{
        let p = new Promise((resolve,reject)=>{
            this.steam.logOn(this.account_details);
            this.steam.on('loggedOn', () => {
                this.steam.setPersona(SteamUser.Steam.EPersonaState.Online);
                this.informations.steamID=this.steam.client.steamID;
                this.informations.accountid=this.steam.steamID.accountid;
                console.log(this.informations);
                this.steam.logOff();
                setTimeout(()=>{
                    resolve(true);
                },1000);
         });
        });
        return p.then((resolve)=>{
            console.log(`...`);
        });
    }

Console:

Attached File  console.png   3.58KB   0 downloads 


Edited by Skyper, 04 January 2019 - 05:38 AM.


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,070 posts

Posted 04 January 2019 - 05:33 PM

I would assume it's because this code is being called multiple times and is attaching a new listener to loggedOn every time.



#3 Skyper

Skyper

    Newbie

  • Member
  • Pip
  • 9 posts

Posted 04 January 2019 - 06:52 PM

It's possible work on same lisener without multiple? Without promise I have normal console log without any double lines but I need promise... Thanks for respond @Dr. McKay!



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,070 posts

Posted 04 January 2019 - 09:11 PM

Given that your steam-user seems to be temporary, you could just create a new one every time.







Also tagged with one or more of these keywords: Question, node.js, node-steam-user

3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users