Jump to content
McKay Development

Van Kappa

Member
  • Posts

    20
  • Joined

  • Last visited

Posts posted by Van Kappa

  1. You should check if loggedOn event's eresult is OK, otherwise there was an error logging in and therefore you can't proceed (request web session cookies).

    Replace:

    client.on('loggedOn', function(details) {
        client.getPersonas([client.steamID], function(personas) {
            console.log("============ Logged in ===============================")
            console.log('== Name: ' + personas[client.steamID]["player_name"]);
            console.log('== ID64: ' + client.steamID);
            console.log("======================================================");
            console.log("");
        });
        console.log();
        client.setPersona(1); // Shows the status as online. 0 = offline (It will still work though!) 1 = online
        setInterval(function() { client.webLogOn(); }, 1000 * 60); // Refreshes session every 10 minutes
    });
    

    with

    client.on('loggedOn', function(details) {
    	if(details.eresult == SteamUser.EResult.OK) {
    		client.getPersonas([client.steamID], function(personas) {
    			console.log("============ Logged in ===============================")
    			console.log('== Name: ' + personas[client.steamID]["player_name"]);
    			console.log('== ID64: ' + client.steamID);
    			console.log("======================================================");
    			console.log("");
    		});
    		console.log();
    		client.setPersona(1); // Shows the status as online. 0 = offline (It will still work though!) 1 = online
    		client.webLogOn();
    	} else {
    		console.log(details);
    		//Do whatever u want to handle the error...
    	}
    });
    
    

    Also, you should rate limit this:

    community.on("sessionExpired", function(err) {
        console.log("## Session Expired, relogging.");
        client.webLogOn();
    });
    

    since it can be triggered too often and make steam temporary block your IP. You can do it like this:

    var lastWebLoginAttempt = 0;
    
    community.on("sessionExpired", function(err) {
        if(Date.now() - lastLoginAttempt >= 30000) {
            lastLoginAttempt = Date.now();
            console.log("## Session Expired, relogging.");
            client.webLogOn();
        } else {
            console.log("## Session Expired, waiting a while before attempting to relogin.");
        }
    });
    
  2. Added a line to log "err" if something comes up. Sadly I can't reproduce the problem. Right now, it's running fine, no errors, handling trades how it should!

     

    Thanks already!

     

    As I said, it should only crash when err is set, as there won't be any data on me nor them. If you added a line to log err, the next time it crashes you should have an error object output just before the crash line

  3. That could be added, yeah. It'd be a new method if I do add it though, for compatibility. Not sure when I'd have the time to work on adding it.

     

    There is something I'm not getting.

    Steam states a method to get trade history, called GetTradeHistory, but, as they explicity show the difference between a Trade and a TradeOffer, I can't understand what'd be the point of this GetTradeHistory method given also that it's already possible to get the TradeOffer history from the GetTradeOffers method.

  4. self.steamInterface.on("webSession",
    		function (sessionID, sessionCookies) {
    			self.sessionID = sessionID;
    			self.sessionCookies = sessionCookies;
    			
    			sessionCookies.forEach(
    				function(cookie) {
    					self.httpRequestJar.setCookie(self.httpRequest.cookie(cookie), 'https://steamcommunity.com');
    				}
    			);
    			
    			self.steamWebInterface.setCookies(sessionCookies);
    			self.steamTradeOffers.setCookies(sessionCookies,
    				function (e) {
    					if(!e) {
    						self.apiKey = self.steamTradeOffers.apiKey;
                                                    //I DO REQUEST getPersonas HERE
    					} else {
    						self.emit("error", e);
    					}
    				}
    			);
    		}
    	);
    	
    	self.steamInterface.on("loggedOn",
    		function (response) {
    			if(response.eresult == steamInterface.EResult.OK) {
    				self.steamInterface.setPersona(steamInterface.EPersonaState.Online, self.nickname);
    			}
    		}
    	);

    Maybe I should wait for an event/callback from setPersona, but how?

  5. Hello, and sorry for bumping!

     

    I am getting this as response, which I supose being invalid:

     

    eAwk3j3.png

     

    My code:

     

    steamUser.getPersonas(["76561198313712684"], function (data) { console.log(data) });
    
    Not sure if helps, but I'm calling this as soon as the webSession event fires (already tried with loggedOn event, same result). Am I missing something?

     

    Thank you :)

×
×
  • Create New...