seishun / node-steam-trade

Node.js wrapper around Steam trading
162 stars 36 forks source link

steamTrade._send error #32

Closed pranaymk closed 10 years ago

pranaymk commented 10 years ago

With my bot I required it to send a trade request and I came across this function, which I think is what I need.

SteamTrade.prototype._send = function(action, data, callback) {
  clearTimeout(this._timerTradePoll);

  data.sessionid = this.sessionID;

  var self = this;

  this._request.post({
    uri: 'http://steamcommunity.com/trade/' + this.tradePartnerSteamID + '/' + action,
    headers: {
      referer: 'http://steamcommunity.com/trade/1'
    },
    form: data,
    json: true
  }, function(error, response, body) {
    if (!self.tradePartnerSteamID) {
      // trade is over already
      return;
    }

    if (error || response.statusCode != 200) {
      self.emit('debug', 'sending ' + action + ': ' + (error || response.statusCode));
      // retry
      self._send(action, data, callback);
      return;
    }

    self._onTradeStatusUpdate(body, callback);
    return;
  });
};

After executing this line of code, I am returned with this error:

C:\Users\<edit>\Documents\GitHub\bot\node_modules\steam-trade\index.js:200
  data.sessionid = this.sessionID;
                 ^
TypeError: Cannot set property 'sessionid' of undefined
    at SteamTrade._send (C:\Users\<edit>\Documents\GitHub\bot\node_modules\steam
-trade\index.js:200:18)
    at SteamClient.<anonymous> (C:\Users\<edit>\Documents\GitHub\bot\BotTCserver
.js:131:14)
    at SteamClient.EventEmitter.emit (events.js:98:17)
    at SteamClient.<anonymous> (C:\Users\<edit>\Documents\GitHub\bot\node_module
s\steam\lib\handlers\friends.js:172:12)
    at Array.forEach (native)
    at SteamClient.handlers.(anonymous function) (C:\Users\<edit>\Documents\GitH
ub\bot\node_modules\steam\lib\handlers\friends.js:168:32)
    at SteamClient._netMsgReceived (C:\Users\<edit>\Documents\GitHub\bot\node_mo
dules\steam\lib\steam_client.js:102:26)
    at SteamClient.handlers.(anonymous function) (C:\Users\<edit>\Documents\GitH
ub\bot\node_modules\steam\lib\steam_client.js:188:10)
    at SteamClient._netMsgReceived (C:\Users\<edit>\Documents\GitHub\bot\node_mo
dules\steam\lib\steam_client.js:102:26)
    at Connection.EventEmitter.emit (events.js:95:17)

C:\Users\<edit>\Documents\GitHub\bot>PAUSE
Press any key to continue . . .

I think this may be down to the way I have implemented it. But I am not really quite sure what to do.

seishun commented 10 years ago

No, _send is a private function. Sending trade requests is done via Steam CM. If you're using node-steam, use this.