seishun / node-steam

Interface directly with Steam servers from Node.js
MIT License
1k stars 180 forks source link

General usage issue and missunderstanding #347

Closed iJamesPHP closed 8 years ago

iJamesPHP commented 8 years ago

Hey there,

I'm developing a CS:GO coinflipping website and I have set up the login with steam system and have all of my users in a database.

I'm now working on the part that lets them deposit their skins into the site and they get exchanged for coins relative to the skin's value.

I've been looking around for how to send tradeoffers via JS or PHP and have come across node-steam and it's addons like node-steam-tradeoffers.

I have afew questions about it's usage:

var fs = require('fs'); var Steam = require('steam');

// if we've saved a server list, use it if (fs.existsSync('servers')) { Steam.servers = JSON.parse(fs.readFileSync('servers')); }

var steamClient = new Steam.SteamClient(); var steamUser = new Steam.SteamUser(steamClient); var steamFriends = new Steam.SteamFriends(steamClient);

steamClient.connect(); steamClient.on('connected', function() { steamUser.logOn({ account_name: '.', password: '.' }); });

steamClient.on('logOnResponse', function(logonResp) { if (logonResp.eresult == Steam.EResult.OK) { console.log('Logged in!'); steamFriends.setPersonaState(Steam.EPersonaState.Online); // to display your bot's status as "Online" steamFriends.setPersonaName('Haruhi'); // to change its nickname //steamFriends.joinChat('103582791431621417'); // the group's SteamID as a string } });

Obviously I have my account username an dpassword within the account_name and password values.

Every time I run the code by cding into the "steam" folder and running "node example.js" I always get the same error output:

Jamess-MacBook-Pro:steam James$ node example.js events.js:141 throw er; // Unhandled 'error' event ^

Error: Disconnected at SteamClient._disconnected (/Users/James/Sites/CSFlip/node_modules/steam/lib/steam_client.js:186:24) at emitOne (events.js:77:13) at Connection.emit (events.js:169:7) at TCP._onclose (net.js:469:12) Jamess-MacBook-Pro:steam James$

This is a really key part of my site and if I can't get past this obstacle I won't be able to complete it, thanks for any help on this issue!

tobbbles commented 8 years ago

Please wrape you code in code tags, backticks.

You don't write your code in the node_modules folder.

This isn't a helpdesk, however if you move your code out into the proper directory, read the proper documentation, I'm sure you can fix it. :smiley:

scholtzm commented 8 years ago

As per README, you need to handle the error event.

seishun commented 8 years ago

First, this isn't a help desk. Second, you need to read a Node.js tutorial to understand how modules work in general. Third. you should read the READMEs of modules you use before creating issues - as your stack trace clearly shows, you didn't handle the 'error' event.