Skip to content

Commit

Permalink
Merge pull request #15 from TrueCarry/master
Browse files Browse the repository at this point in the history
Updated readme
  • Loading branch information
joshuaferrara committed Aug 2, 2015
2 parents 30cf270 + a22ab5b commit 2f78b44
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 11 deletions.
92 changes: 89 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ Based on [node-dota2](https://github.com/RJacksonm1/node-dota2) by [RJacksonm1](

# Initializing
Parameters:
* `steamClient` - Pass a SteamClient instance to use to send & receive GC messages.
* `steamUser` - Pass a SteamUser instance to change your current status(In-game/not).
* `steamGC` - Pass a SteamGameCoordinator instance to use to send & receive GC messages.
* `debug` - A boolean noting whether to print information about operations to console.

```js
var Steam = require('steam'),
steamClient = new Steam.SteamClient(),
steamUser = new Steam.SteamUser(steamClient),
steamGC = new Steam.SteamGameCoordinator(steamClient, 730);
csgo = require('csgo'),
CSGO = new csgo.CSGOClient(steamClient, true);
CSGO = new csgo.CSGOClient(steamUser, steamGC, false),
```

# Methods
Expand Down Expand Up @@ -67,6 +70,40 @@ Sends a message to the Game Coordinator requesting some matchmaking stats. Liste

Requests a list of recent games for the given accountId. Listen for the `matchList` event for the game coordinator's response.

### `requestLiveGameForUser(accountId)`

Requests current live game info for given user. Listen for the `matchList` event for the game coordinator's response.

### `requestGame(matchid, outcomeid, token)`

Requests info about game. We still don't know for sure what we should use as outcomeid and token. Listen for the `matchList` event for the game coordinator's response.

### `requestWatchInfoFriends(arguments)`

Requests watchable info for game.
Arguments:
```javascript
int request_id; //Not enough tests yet
account_ids[array_of_csgo_accounts];//Not enough tests yet
long serverid;//ServerID of match.
long matchid;//MatchID of match.
```
Example:
```javascript
CSGO.requestWatchInfoFriends({
serverid: new Long(-569600767, -2130640678, true).toString(),
matchid: new Long(39, 719230023, true).toString()
});
```
Requirements: game should be live.

Listen for the `watchList` event for the game coordinator's response.

### `requestCurrentLiveGames()`

Requests a list of current live games. Listen for the `matchList` event for the game coordinator's response.


## Player Info

### `playerProfileRequest(accountId)`
Expand Down Expand Up @@ -442,4 +479,53 @@ The whole response ended up being too big for the readme and caused browsers to
}
```

Emitted when `requestRecentGames` is replied to.
Emitted when `requestRecentGames`, `requestGame`, `requestLiveGameForUser`, `requestCurrentLiveGames` is replied to.

## `watchList` (Response to `requestWatchInfoFriends`)
Example:
```json
{
"request_id": 0,
"account_ids": [],
"watchable_match_infos": [
{
"server_ip": 2453839835,
"tv_port": 28056,
"tv_spectators": 1,
"tv_time": 417,
"tv_watch_password": {
"buffer": {
"type": "Buffer",
"data": [ ]
},
"offset": 21,
"markedOffset": -1,
"limit": 53,
"littleEndian": true,
"noAssert": false
},
"cl_decryptdata_key": null,
"cl_decryptdata_key_pub": {
"low": -249571153,
"high": 1941167002,
"unsigned": true
},
"game_type": 32776,
"game_mapgroup": "mg_de_mirage",
"game_map": "de_mirage",
"server_id": {
"low": 2054631424,
"high": 20977258,
"unsigned": true
},
"match_id": {
"low": 32,
"high": 719254593,
"unsigned": true
},
"reservation_id": null
}
],
"extended_timeout": null
}
```
2 changes: 1 addition & 1 deletion example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var Steam = require("steam"),
steamUser = new Steam.SteamUser(bot),
steamFriends = new Steam.SteamFriends(bot),
steamGC = new Steam.SteamGameCoordinator(bot, 730);
CSGO = new csgo.CSGOClient(bot, steamUser, steamGC, false),
CSGO = new csgo.CSGOClient(steamUser, steamGC, false),
readlineSync = require("readline-sync"),
crypto = require("crypto");

Expand Down
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ var EventEmitter = require('events').EventEmitter,
bignumber = require("bignumber.js"),
CSGO = exports;

var CSGOClient = function CSGOClient(steamClient, steamUser, steamGC, debug) {
var CSGOClient = function CSGOClient(steamUser, steamGC, debug) {
EventEmitter.call(this);

this.debug = debug || false;
this._client = steamClient;
this._user = steamUser;
this._gc = steamGC;
this._appid = 730;
Expand Down Expand Up @@ -43,8 +42,8 @@ var CSGOClient = function CSGOClient(steamClient, steamUser, steamGC, debug) {
if (self.debug) {
util.log("Sending ClientHello");
}
if (!self._client) {
util.log("Client went missing");
if (!self._gc) {
util.log("GC went missing");
}
else {
self._gc.send({msg: CSGO.EGCBaseClientMsg.k_EMsgGCClientHello, proto: {}},
Expand Down Expand Up @@ -91,11 +90,13 @@ CSGOClient.prototype.exit = function() {

/* stop knocking if exit comes before ready event */
if (this._gcClientHelloIntervalId) {
clearInterval(this._gcClientHelloIntervalId);
this._gcClientHelloIntervalId = null;
clearInterval(this._gcClientHelloIntervalId);
this._gcClientHelloIntervalId = null;
}
this._gcReady = false;
this._client.gamesPlayed([]);
this._user.gamesPlayed({
games_played: [{}]
});
};


Expand Down

0 comments on commit 2f78b44

Please sign in to comment.