{"action":"created","issue":{"url":"https://api.github.com/repos/RJacksonm1/node-dota2/issues/177","labels_url":"https://api.github.com/repos/RJacksonm1/node-dota2/issues/177/labels{/name}","comments_url":"https://api.github.com/repos/RJacksonm1/node-dota2/issues/177/comments","events_url":"https://api.github.com/repos/RJacksonm1/node-dota2/issues/177/events","html_url":"https://github.com/RJacksonm1/node-dota2/pull/177","id":121112130,"number":177,"title":"Refactoring according to #107","user":{"login":"Crazy-Duck","id":11719463,"avatar_url":"https://avatars.githubusercontent.com/u/11719463?v=3","gravatar_id":"","url":"https://api.github.com/users/Crazy-Duck","html_url":"https://github.com/Crazy-Duck","followers_url":"https://api.github.com/users/Crazy-Duck/followers","following_url":"https://api.github.com/users/Crazy-Duck/following{/other_user}","gists_url":"https://api.github.com/users/Crazy-Duck/gists{/gist_id}","starred_url":"https://api.github.com/users/Crazy-Duck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Crazy-Duck/subscriptions","organizations_url":"https://api.github.com/users/Crazy-Duck/orgs","repos_url":"https://api.github.com/users/Crazy-Duck/repos","events_url":"https://api.github.com/users/Crazy-Duck/events{/privacy}","received_events_url":"https://api.github.com/users/Crazy-Duck/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RJacksonm1/node-dota2/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/RJacksonm1/node-dota2/labels/needs%20testing","name":"needs testing","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-12-08T22:17:29Z","updated_at":"2015-12-17T06:30:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/RJacksonm1/node-dota2/pulls/177","html_url":"https://github.com/RJacksonm1/node-dota2/pull/177","diff_url":"https://github.com/RJacksonm1/node-dota2/pull/177.diff","patch_url":"https://github.com/RJacksonm1/node-dota2/pull/177.patch"},"body":"Alright, paging everyone to see if their stuff still works. \r\n@howardchung did I break yasp?\r\n@imayhaveborkedit did I bork it?\r\n@jimmydorry is it a classic jimmy?"},"comment":{"url":"https://api.github.com/repos/RJacksonm1/node-dota2/issues/comments/165356098","html_url":"https://github.com/RJacksonm1/node-dota2/pull/177#issuecomment-165356098","issue_url":"https://api.github.com/repos/RJacksonm1/node-dota2/issues/177","id":165356098,"user":{"login":"Crazy-Duck","id":11719463,"avatar_url":"https://avatars.githubusercontent.com/u/11719463?v=3","gravatar_id":"","url":"https://api.github.com/users/Crazy-Duck","html_url":"https://github.com/Crazy-Duck","followers_url":"https://api.github.com/users/Crazy-Duck/followers","following_url":"https://api.github.com/users/Crazy-Duck/following{/other_user}","gists_url":"https://api.github.com/users/Crazy-Duck/gists{/gist_id}","starred_url":"https://api.github.com/users/Crazy-Duck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Crazy-Duck/subscriptions","organizations_url":"https://api.github.com/users/Crazy-Duck/orgs","repos_url":"https://api.github.com/users/Crazy-Duck/repos","events_url":"https://api.github.com/users/Crazy-Duck/events{/privacy}","received_events_url":"https://api.github.com/users/Crazy-Duck/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T06:30:37Z","updated_at":"2015-12-17T06:30:37Z","body":"For the moment if a call fails due to any reason _other_ than GC not ready, one of our handlers is called. Our handlers already know how to interpret the messages we receive from the GC, even when the GC returns an error (it doesn't make much sense to create a generic GC error handler, seeing as the business varies based on the call, furthermore, the problem isn't in the handling of the GC response). Subsequently, our handlers invoke the user-provided callbacks and pass them an error message. However, before a message is sent to the GC, our code does a check to see if the GC is ready. If it isn't, nothing happens and there is no feedback to the user; this is the behaviour we'd like to change. The way it's implemented now, we can't directly invoke the user-provided callback, because the one we receive as input to the helper function is a reference to one of our handlers. What I'm proposing is changing our helper function to the following (not yet tested):\r\n```JavaScript\r\nDota2Client.prototype.sendToGC = function(type, payload, handler, callback) {\r\n    if (!this._gcReady) {\r\n        if (this.debug) util.log(\"GC not ready, please listen for the 'ready' event.\");\r\n        if (callback) callback(-1, null); // tbd what we return here\r\n    } else {\r\n        this._protoBufHeader.msg = type;\r\n        this._gc.send(this._protoBufHeader, payload.toBuffer(), Dota2._convertCallback(handler, callback));\r\n    }\r\n}\r\n```"}}