diff --git a/classes/CMarketItem.js b/classes/CMarketItem.js index 7b40a6e..08c4baa 100644 --- a/classes/CMarketItem.js +++ b/classes/CMarketItem.js @@ -26,7 +26,7 @@ SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, cal callback(null, item); } }); - }); + }, "steamcommunity"); }; function CMarketItem(appid, hashName, community, body, $) { @@ -137,7 +137,7 @@ CMarketItem.prototype.updatePriceForCommodity = function(currency, callback) { if(callback) { callback(null); } - }); + }, "steamcommunity"); }; CMarketItem.prototype.updatePriceForNonCommodity = function (currency, callback) { @@ -181,5 +181,5 @@ CMarketItem.prototype.updatePriceForNonCommodity = function (currency, callback) } callback && callback(null); - }); + }, "steamcommunity"); }; diff --git a/classes/CMarketSearchResult.js b/classes/CMarketSearchResult.js index 8244370..396d895 100644 --- a/classes/CMarketSearchResult.js +++ b/classes/CMarketSearchResult.js @@ -71,7 +71,7 @@ function performSearch(request, qs, results, callback) { qs.start += body.pagesize; performSearch.call(self, request, qs, results, callback); } - }); + }, "steamcommunity"); } function CMarketSearchResult(row) { diff --git a/classes/CSteamGroup.js b/classes/CSteamGroup.js index fe367d9..c4e5241 100644 --- a/classes/CSteamGroup.js +++ b/classes/CSteamGroup.js @@ -29,7 +29,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) { callback(null, new CSteamGroup(self, result.memberList)); }); - }); + }, "steamcommunity"); }; function CSteamGroup(community, groupData) { diff --git a/classes/CSteamUser.js b/classes/CSteamUser.js index 1c19fef..69f0cae 100644 --- a/classes/CSteamUser.js +++ b/classes/CSteamUser.js @@ -48,7 +48,7 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) { callback(null, new CSteamUser(self, result.profile, customurl)); }); - }); + }, "steamcommunity"); }; function CSteamUser(community, userData, customurl) { diff --git a/components/chat.js b/components/chat.js index a06f775..c36eb8d 100644 --- a/components/chat.js +++ b/components/chat.js @@ -82,7 +82,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) { self.chatState = SteamCommunity.ChatState.LoggedOn; self.emit('chatLoggedOn'); self._chatPoll(); - }); + }, "steamcommunity"); }); }; @@ -127,7 +127,7 @@ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) } else { callback(null); } - }); + }, "steamcommunity"); }; SteamCommunity.prototype.chatLogoff = function() { @@ -149,7 +149,7 @@ SteamCommunity.prototype.chatLogoff = function() { delete self.chatFriends; self.chatState = SteamCommunity.ChatState.Offline; } - }); + }, "steamcommunity"); }; SteamCommunity.prototype._chatPoll = function() { @@ -211,7 +211,7 @@ SteamCommunity.prototype._chatPoll = function() { self.emit('debug', 'Unhandled chat message type: ' + message.type); } }); - }); + }, "steamcommunity"); }; SteamCommunity.prototype._chatUpdatePersona = function(steamID) { @@ -242,5 +242,5 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) { self.emit('chatPersonaState', steamID, persona); self.chatFriends[steamID.getSteamID64()] = persona; - }); + }, "steamcommunity"); }; \ No newline at end of file diff --git a/components/confirmations.js b/components/confirmations.js index bc03279..fe7d329 100644 --- a/components/confirmations.js +++ b/components/confirmations.js @@ -158,7 +158,7 @@ function request(community, url, key, time, tag, params, json, callback) { } callback(null, body); - }); + }, "steamcommunity"); } // Confirmation checker diff --git a/components/groups.js b/components/groups.js index 73e537c..13b990e 100644 --- a/components/groups.js +++ b/components/groups.js @@ -60,7 +60,7 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link callback(null, members); } }); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.getGroupMembersEx = function(gid, addresses, callback) { @@ -94,7 +94,7 @@ SteamCommunity.prototype.joinGroup = function(gid, callback) { } callback(null); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.leaveGroup = function(gid, callback) { @@ -172,7 +172,7 @@ SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback return callback(null, announcements); }); - }); + }, "steamcommunity"); } SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, callback) { @@ -205,7 +205,7 @@ SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content } callback(null); - }) + }, "steamcommunity"); }; SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, content, callback) { @@ -243,7 +243,7 @@ SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, co } callback(null); - }) + }, "steamcommunity"); }; SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) { @@ -254,8 +254,8 @@ SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) var self = this; var submitData = { - "uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID(), - } + "uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID() + }; this.httpRequestGet(submitData, function(err, response, body) { if(!callback) { @@ -271,7 +271,7 @@ SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) } callback(null); - }) + }, "steamcommunity"); }; SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) { @@ -337,7 +337,7 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript } callback(null); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callback) { @@ -380,7 +380,7 @@ SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callba callback(new Error(results.response.results[0])); } }); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) { @@ -416,7 +416,7 @@ SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) { } callback(null); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) { @@ -499,5 +499,5 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) { }); callback(null, output); - }); + }, "steamcommunity"); }; diff --git a/components/http.js b/components/http.js index f4d7368..b5b6d94 100644 --- a/components/http.js +++ b/components/http.js @@ -1,7 +1,8 @@ var SteamCommunity = require('../index.js'); -SteamCommunity.prototype.httpRequest = function(uri, options, callback, method) { +SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) { if (typeof uri === 'object') { + source = callback; callback = options; options = uri; uri = options.url || options.uri; @@ -14,7 +15,10 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, method) delete this._httpRequestConvenienceMethod; } - if (this.onPreHttpRequest && this.onPreHttpRequest(options, callback) === false) { + var requestID = ++this._httpRequestID; + source = source || ""; + + if (this.onPreHttpRequest && this.onPreHttpRequest(requestID, source, options, callback) === false) { return false; } @@ -25,7 +29,7 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, method) var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function() {} : callback); // don't fire the callback if hasHttpError did it already var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function() {} : callback); // don't fire the callback if either of the previous already did - self.emit('postHttpRequest', httpError || communityError || tradeError || null, response, body, { + self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || null, response, body, { "hasCallback": hasCallback, "httpError": httpError, "communityError": communityError, diff --git a/components/inventoryhistory.js b/components/inventoryhistory.js index 008ace4..0d21137 100644 --- a/components/inventoryhistory.js +++ b/components/inventoryhistory.js @@ -122,7 +122,7 @@ SteamCommunity.prototype.getInventoryHistory = function(options, callback) { } else { callback(null, output); } - }); + }, "steamcommunity"); }; function resolveVanityURL(vanityURL, callback) { diff --git a/components/market.js b/components/market.js index ebd714a..65f70de 100644 --- a/components/market.js +++ b/components/market.js @@ -21,5 +21,5 @@ SteamCommunity.prototype.getMarketApps = function(callback) { } else { callback(new Error("Malformed response")); } - }); -} + }, "steamcommunity"); +}; diff --git a/components/profile.js b/components/profile.js index 856d4ec..4aa6033 100644 --- a/components/profile.js +++ b/components/profile.js @@ -237,7 +237,7 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) { } doUpload(body); - }) + }, "steamcommunity"); } else { if(!format) { format = image.match(/\.([^\.]+)$/); @@ -354,6 +354,6 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) { if(callback) { callback(null, body.images.full); } - }); + }, "steamcommunity"); } }; diff --git a/components/twofactor.js b/components/twofactor.js index d98d0b1..b134f40 100644 --- a/components/twofactor.js +++ b/components/twofactor.js @@ -45,7 +45,7 @@ SteamCommunity.prototype.enableTwoFactor = function(callback) { } callback(null, body.response); - }); + }, "steamcommunity"); }); }; @@ -104,7 +104,7 @@ SteamCommunity.prototype.finalizeTwoFactor = function(secret, activationCode, ca } else { callback(null); } - }); + }, "steamcommunity"); } }; @@ -149,6 +149,6 @@ SteamCommunity.prototype.disableTwoFactor = function(revocationCode, callback) { var error = new Error("Cannot remove authenticator (" + body.response.status + ")"); error.eresult = body.response.status; callback(error); - }); + }, "steamcommunity"); }); }; diff --git a/components/users.js b/components/users.js index 2077321..a1d892d 100644 --- a/components/users.js +++ b/components/users.js @@ -30,7 +30,7 @@ SteamCommunity.prototype.addFriend = function(userID, callback) { } else { callback(new Error("Unknown error")); } - }); + }, "steamcommunity"); }; SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) { @@ -56,7 +56,7 @@ SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) { } callback(null); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.removeFriend = function(userID, callback) { @@ -81,7 +81,7 @@ SteamCommunity.prototype.removeFriend = function(userID, callback) { } callback(null); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.blockCommunication = function(userID, callback) { @@ -106,7 +106,7 @@ SteamCommunity.prototype.blockCommunication = function(userID, callback) { } callback(null); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.unblockCommunication = function(userID, callback) { @@ -161,7 +161,7 @@ SteamCommunity.prototype.postUserComment = function(userID, message, callback) { } else { callback(new Error("Unknown error")); } - }); + }, "steamcommunity"); }; SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback) { @@ -196,7 +196,7 @@ SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback) } else { callback(new Error("Unknown error")); } - }); + }, "steamcommunity"); }; SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) { @@ -235,7 +235,7 @@ SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) { } callback(null, data); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, tradableOnly, callback) { @@ -298,6 +298,6 @@ SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, t } else { callback(null, inventory, currency); } - }); + }, "steamcommunity"); } }; diff --git a/components/webapi.js b/components/webapi.js index f7ac0d6..9d72b63 100644 --- a/components/webapi.js +++ b/components/webapi.js @@ -33,9 +33,9 @@ SteamCommunity.prototype.getWebApiKey = function(domain, callback) { } self.getWebApiKey(domain, callback); - }); + }, "steamcommunity"); } - }); + }, "steamcommunity"); }; SteamCommunity.prototype.getWebApiOauthToken = function(callback) { @@ -62,5 +62,5 @@ SteamCommunity.prototype.getWebApiOauthToken = function(callback) { } callback(null, match[1]); - }); + }, "steamcommunity"); }; diff --git a/index.js b/index.js index e1c78b5..71a294f 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ function SteamCommunity(options) { this._jar = Request.jar(); this._captchaGid = -1; + this._httpRequestID = 0; this.chatState = SteamCommunity.ChatState.Offline; var defaults = { @@ -156,8 +157,8 @@ SteamCommunity.prototype.login = function(details, callback) { callback(null, sessionID, cookies, steamguard, oAuth.oauth_token); } - }); - }); + }, "steamcommunity"); + }, "steamcommunity"); function deleteMobileCookies() { var cookie = Request.cookie('mobileClientVersion='); @@ -200,7 +201,7 @@ SteamCommunity.prototype.oAuthLogin = function(steamguard, token, callback) { self.setCookies(cookies); callback(null, self.getSessionID(), cookies); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.setCookies = function(cookies) { @@ -259,7 +260,7 @@ SteamCommunity.prototype.parentalUnlock = function(pin, callback) { } callback(); - }.bind(this)); + }.bind(this), "steamcommunity"); }; SteamCommunity.prototype.getNotifications = function(callback) { @@ -295,7 +296,7 @@ SteamCommunity.prototype.getNotifications = function(callback) { } callback(null, notifications); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.resetItemNotifications = function(callback) { @@ -310,7 +311,7 @@ SteamCommunity.prototype.resetItemNotifications = function(callback) { } callback(null); - }); + }, "steamcommunity"); }; SteamCommunity.prototype.loggedIn = function(callback) { @@ -326,7 +327,7 @@ SteamCommunity.prototype.loggedIn = function(callback) { } callback(null, !!response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/), false); - }); + }, "steamcommunity"); }; SteamCommunity.prototype._myProfile = function(endpoint, form, callback) { @@ -353,8 +354,8 @@ SteamCommunity.prototype._myProfile = function(endpoint, form, callback) { options.form = form; } - self.httpRequest(options, callback); - }); + self.httpRequest(options, callback, "steamcommunity"); + }, "steamcommunity"); };