|
1 | 1 | const ByteBuffer = require('bytebuffer'); |
2 | 2 | const EventEmitter = require('events').EventEmitter; |
| 3 | +const {ShareCode} = require('globaloffensive-sharecode'); |
3 | 4 | const SteamID = require('steamid'); |
4 | 5 | const Util = require('util'); |
5 | 6 |
|
@@ -150,6 +151,30 @@ GlobalOffensive.prototype._send = function(type, protobuf, body) { |
150 | 151 | return true; |
151 | 152 | }; |
152 | 153 |
|
| 154 | +GlobalOffensive.prototype.requestGame = function(shareCodeOrDetails) { |
| 155 | + if (typeof shareCodeOrDetails == 'string') { |
| 156 | + shareCodeOrDetails = (new ShareCode(shareCodeOrDetails)).decode(); |
| 157 | + } |
| 158 | + |
| 159 | + if (typeof shareCodeOrDetails != 'object' || !shareCodeOrDetails) { |
| 160 | + throw new Error('shareCodeOrDetails must be a sharecode or an object with properties matchId, outcomeId, token'); |
| 161 | + } |
| 162 | + |
| 163 | + let requiredProps = ['matchId', 'outcomeId', 'token']; |
| 164 | + requiredProps.sort(); |
| 165 | + let extantProps = Object.keys(shareCodeOrDetails); |
| 166 | + extantProps.sort(); |
| 167 | + if (extantProps.join() != requiredProps.join()) { |
| 168 | + throw new Error('shareCodeOrDetails must be a sharecode or an object with properties matchId, outcomeId, token'); |
| 169 | + } |
| 170 | + |
| 171 | + this._send(Language.MatchListRequestFullGameInfo, Protos.CMsgGCCStrike15_v2_MatchListRequestFullGameInfo, { |
| 172 | + matchid: shareCodeOrDetails.matchId, |
| 173 | + outcomeid: shareCodeOrDetails.outcomeId, |
| 174 | + token: shareCodeOrDetails.token |
| 175 | + }); |
| 176 | +}; |
| 177 | + |
153 | 178 | GlobalOffensive.prototype.requestLiveGames = function() { |
154 | 179 | this._send(Language.MatchListRequestCurrentLiveGames, Protos.CMsgGCCStrike15_v2_MatchListRequestCurrentLiveGames, {}); |
155 | 180 | }; |
|
0 commit comments