Skip to content

Commit

Permalink
Fix from CounterStrike2GSI
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpup committed Jan 20, 2024
1 parent db872e8 commit 7e24108
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
49 changes: 31 additions & 18 deletions Dota2GSI/GameStateListener.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Dota2GSI.EventMessages;
using Dota2GSI.EventMessages;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
Expand Down Expand Up @@ -43,13 +43,24 @@ public GameState CurrentGameState
{
get
{
return _current_game_state;
lock (gamestate_lock)
{
return _current_game_state;
}
}
private set
{
_previous_game_state = _current_game_state;
_current_game_state = value;
RaiseOnNewGameState(ref _current_game_state);
lock (gamestate_lock)
{
if (_current_game_state.Equals(value))
{
return;
}

_previous_game_state = _current_game_state;
_current_game_state = value;
RaiseOnNewGameState(ref _current_game_state);
}
}
}

Expand All @@ -58,9 +69,9 @@ private set
/// </summary>
public int Port => _port;

/// <summary>
/// Gets the URI that is being listened.
/// </summary>
/// <summary>
/// Gets the URI that is being listened.
/// </summary>
public string URI => _uri;

/// <summary>
Expand All @@ -73,6 +84,8 @@ private set
/// </summary>
public event NewGameStateHandler NewGameState = delegate { };

private readonly object gamestate_lock = new object();

private bool _is_running = false;
private int _port;
private string _uri;
Expand Down Expand Up @@ -117,12 +130,12 @@ private GameStateListener()
}

/// <summary>
/// A GameStateListener that listens for connections on http://localhost:port/.
/// A GameStateListener that listens for connections on http://localhost:<c>port</c>/.
/// </summary>
/// <param name="Port">The port to listen on.</param>
public GameStateListener(int Port) : this()
/// <param name="port">The port to listen on.</param>
public GameStateListener(int port) : this()
{
_port = Port;
_port = port;
_uri = $"http://localhost:{_port}/";
_http_listener = new HttpListener();
_http_listener.Prefixes.Add(_uri);
Expand Down Expand Up @@ -153,11 +166,11 @@ public GameStateListener(string URI) : this()
_http_listener.Prefixes.Add(URI);
}

/// <summary>
/// Attempts to create a Game State Integration configuraion file.
/// </summary>
/// <param name="name">The name of your integration.</param>
/// <returns>Returns true on success, false otherwise.</returns>
/// <summary>
/// Attempts to create a Game State Integration configuraion file.
/// </summary>
/// <param name="name">The name of your integration.</param>
/// <returns>Returns true on success, false otherwise.</returns>
public bool GenerateGSIConfigFile(string name)
{
return Dota2GSIFile.CreateFile(name, _uri);
Expand Down Expand Up @@ -247,7 +260,7 @@ private void RaiseOnNewGameState(ref GameState game_state)
{
RaiseEvent(NewGameState, game_state);

_game_state_handler.OnNewGameState(CurrentGameState);
_game_state_handler.OnNewGameState(game_state);
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Dota2GSI/Nodes/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public override bool Equals(object obj)
}

return obj is Node other &&
_ParsedData != null &&
_ParsedData.Equals(other._ParsedData) &&
_successfully_retrieved_any_value.Equals(other._successfully_retrieved_any_value);
}
Expand Down

0 comments on commit 7e24108

Please sign in to comment.