Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpup committed Jan 20, 2024
1 parent 0e963ee commit cda648b
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,7 @@ Install from [nuget](https://www.nuget.org/packages/Dota2GSI).

## How to use

1. Before `Dota2GSI` can be used, you must create a Game State Integration configuration file where you would specify the URI for the HTTP Requests and select which providers the game should expose to your application. To do this you must create a new configuration file in `<PATH TO GAME DIRECTORY>/game/dota/cfg/gamestate_integration/gamestate_integration_<CUSTOM NAME>.cfg` where `<CUSTOM NAME>` should be the name of your application (it can be anything). Add the following content to your configuration file (make sure you replace `<CUSTOM NAME>` with your application's name, `<CUSTOM PORT>` with the port you would like to use for your application, and other values can also be tweaked as you wish):
```
"<CUSTOM NAME> Integration Configuration"
{
"uri" "http://localhost:<CUSTOM PORT>/"
"timeout" "5.0"
"buffer" "0.1"
"throttle" "0.1"
"heartbeat" "30.0"
"data"
{
"auth" "1"
"provider" "1"
"map" "1"
"player" "1"
"hero" "1"
"abilities" "1"
"items" "1"
"events" "1"
"buildings" "1"
"league" "1"
"draft" "1"
"wearables" "1"
"minimap" "1"
"roshan" "1"
"couriers" "1"
"neutralitems" "1"
}
}
```

2. After installing the [Dota2GSI nuget package](https://www.nuget.org/packages/Dota2GSI) in your project, create an instance of `GameStateListener`, providing a custom port or custom URI you defined in the configuration file in the previous step.
1. After installing the [Dota2GSI nuget package](https://www.nuget.org/packages/Dota2GSI) in your project, create an instance of `GameStateListener`, providing a custom port or custom URI you defined in the configuration file in the previous step.
```C#
GameStateListener gsl = new GameStateListener(3000); //http://localhost:3000/
```
Expand All @@ -73,6 +42,44 @@ GameStateListener gsl = new GameStateListener("http://127.0.0.1:1234/");
```
> **Please note**: If your application needs to listen to a URI other than `http://localhost:*/` (for example `http://192.168.0.2:100/`), you will need to run your application with administrator privileges.
2. Create a Game State Integration configuration file. This can either be done manually by creating a file `<PATH TO GAME DIRECTORY>/game/dota/cfg/gamestate_integration/gamestate_integration_<CUSTOM NAME>.cfg` where `<CUSTOM NAME>` should be the name of your application (it can be anything). Or you can use the built-in function `GenerateGSIConfigFile()` to automatically locate the game directory and generate the file. The function will automatically take into consideration the URI or port specified when a `GameStateListener` instance was created in the previous step.
```C#
if (!gsl.GenerateGSIConfigFile("Example"))
{
Console.WriteLine("Could not generate GSI configuration file.");
}
```
The function `GenerateGSIConfigFile` takes a string `name` as the parameter. This is the `<CUSTOM NAME>` mentioned earlier. The function will also return `True` when file generation was successful, and `False` otherwise. The resulting file from the above code should look like this:
```
"Example Integration Configuration"
{
"uri" "http://localhost:3000/"
"timeout" "5.0"
"buffer" "0.1"
"throttle" "0.1"
"heartbeat" "10.0"
"data"
{
"auth" "1"
"provider" "1"
"map" "1"
"player" "1"
"hero" "1"
"abilities" "1"
"items" "1"
"events" "1"
"buildings" "1"
"league" "1"
"draft" "1"
"wearables" "1"
"minimap" "1"
"roshan" "1"
"couriers" "1"
"neutralitems" "1"
}
}
```

3. Create handlers and subscribe for events your application will be using. (A full list of exposed Game Events can be found in the [Implemented Game Events](#implemented-game-events) section.)
If your application just needs `GameState` information, this is done by subscribing to `NewGameState` event and creating a handler for it:
```C#
Expand Down

0 comments on commit cda648b

Please sign in to comment.