Only handle events of own steamid
This commit is contained in:
parent
f77f5bc3b4
commit
8526c6b00b
@ -12,9 +12,15 @@ public class CS2MessageHandler
|
||||
public event CS2EventHandler? OnRoundWin;
|
||||
public event CS2EventHandler? OnRoundLoss;
|
||||
|
||||
public void HandleCS2Message(string message)
|
||||
public void HandleCS2Message(string message, string mySteamId)
|
||||
{
|
||||
JObject messageJson = JObject.Parse(message);
|
||||
string? steamId = messageJson.SelectToken("player.steamid", false)?.Value<string>();
|
||||
if (steamId is null || steamId != mySteamId)
|
||||
{
|
||||
Console.WriteLine("Not my steamid");
|
||||
return;
|
||||
}
|
||||
|
||||
RoundState currentRoundState = ParseRoundStateFromString(messageJson.SelectToken("round.phase", false)?.Value<string>());
|
||||
RoundState previousRoundState = ParseRoundStateFromString(messageJson.SelectToken("previously.round.phase", false)?.Value<string>());
|
||||
|
@ -64,6 +64,6 @@ public class OpenCS2hock
|
||||
Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "CS2Events"));
|
||||
string fileName = Path.Combine(Environment.CurrentDirectory, "CS2Events" ,$"{DateTime.Now.ToLongTimeString().Replace(':','.')}.json");
|
||||
File.WriteAllText(fileName, content);
|
||||
_cs2MessageHandler.HandleCS2Message(content);
|
||||
_cs2MessageHandler.HandleCS2Message(content, _settings.SteamId);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ namespace OpenCS2hock;
|
||||
|
||||
public struct Settings
|
||||
{
|
||||
public string SteamId = "";
|
||||
public OpenShockSettings OpenShockSettings = new()
|
||||
{
|
||||
Endpoint = "https://api.shocklink.net",
|
||||
|
Loading…
Reference in New Issue
Block a user