diff --git a/Dota2GSI/GameStateListener.cs b/Dota2GSI/GameStateListener.cs
index 5c5ce7f..ac93dde 100644
--- a/Dota2GSI/GameStateListener.cs
+++ b/Dota2GSI/GameStateListener.cs
@@ -1,4 +1,4 @@
-using Dota2GSI.EventMessages;
+using Dota2GSI.EventMessages;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
@@ -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);
+ }
}
}
@@ -58,9 +69,9 @@ private set
///
public int Port => _port;
- ///
- /// Gets the URI that is being listened.
- ///
+ ///
+ /// Gets the URI that is being listened.
+ ///
public string URI => _uri;
///
@@ -73,6 +84,8 @@ private set
///
public event NewGameStateHandler NewGameState = delegate { };
+ private readonly object gamestate_lock = new object();
+
private bool _is_running = false;
private int _port;
private string _uri;
@@ -117,12 +130,12 @@ private GameStateListener()
}
///
- /// A GameStateListener that listens for connections on http://localhost:port/.
+ /// A GameStateListener that listens for connections on http://localhost:port/.
///
- /// The port to listen on.
- public GameStateListener(int Port) : this()
+ /// The port to listen on.
+ public GameStateListener(int port) : this()
{
- _port = Port;
+ _port = port;
_uri = $"http://localhost:{_port}/";
_http_listener = new HttpListener();
_http_listener.Prefixes.Add(_uri);
@@ -153,11 +166,11 @@ public GameStateListener(string URI) : this()
_http_listener.Prefixes.Add(URI);
}
- ///
- /// Attempts to create a Game State Integration configuraion file.
- ///
- /// The name of your integration.
- /// Returns true on success, false otherwise.
+ ///
+ /// Attempts to create a Game State Integration configuraion file.
+ ///
+ /// The name of your integration.
+ /// Returns true on success, false otherwise.
public bool GenerateGSIConfigFile(string name)
{
return Dota2GSIFile.CreateFile(name, _uri);
@@ -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);
}
///
diff --git a/Dota2GSI/Nodes/Node.cs b/Dota2GSI/Nodes/Node.cs
index ec3a50f..4b6dcd7 100644
--- a/Dota2GSI/Nodes/Node.cs
+++ b/Dota2GSI/Nodes/Node.cs
@@ -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);
}