Compare commits

..

No commits in common. "6ce91bbae7159934a1fdf373248868eb3a02c695" and "1d6699ed8a31324493479df4fad2d2317401711e" have entirely different histories.

2 changed files with 14 additions and 17 deletions

View File

@ -33,17 +33,14 @@ internal static class CS2EventGenerator
if(newGameState.Round?.Phase == Round.RoundPhase.Over && lastGameState.Round?.Phase == Round.RoundPhase.Live) if(newGameState.Round?.Phase == Round.RoundPhase.Over && lastGameState.Round?.Phase == Round.RoundPhase.Live)
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundOver, new CS2EventArgs())); events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundOver, new CS2EventArgs()));
if (newGameState.Map?.Round is not null && newGameState.Map?.Round != previousPlayerState.Map?.Round)
{
if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam == previousPlayerState.Player?.Team) if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam == previousPlayerState.Player?.Team)
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundWin, new CS2EventArgs())); events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundWin, new CS2EventArgs()));
if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam != previousPlayerState.Player?.Team) if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam != previousPlayerState.Player?.Team)
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundLoss, new CS2EventArgs())); events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundLoss, new CS2EventArgs()));
} }
}
if(newGameState.Map?.Phase == Map.MapPhase.Live && lastGameState.Map?.Phase == Map.MapPhase.Warmup) if(newGameState.Map?.Phase == Map.MapPhase.Live && lastGameState.Map?.Phase != Map.MapPhase.Live)
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnMatchStart, new CS2EventArgs())); events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnMatchStart, new CS2EventArgs()));
if(newGameState.Map?.Phase == Map.MapPhase.GameOver && lastGameState.Map?.Phase != Map.MapPhase.GameOver) if(newGameState.Map?.Phase == Map.MapPhase.GameOver && lastGameState.Map?.Phase != Map.MapPhase.GameOver)

View File

@ -19,20 +19,20 @@ internal class GSIServer
{ {
this.logger = logger; this.logger = logger;
string prefix = $"http://127.0.0.1:{port}/"; string prefix = $"http://127.0.0.1:{port}/";
this.HttpListener = new HttpListener(); HttpListener = new HttpListener();
this.HttpListener.Prefixes.Add(prefix); HttpListener.Prefixes.Add(prefix);
this.HttpListener.Start(); HttpListener.Start();
this.logger?.Log(LogLevel.Information, $"Listening on {prefix}"); this.logger?.Log(LogLevel.Information, $"Listening on {prefix}");
Thread connectionListener = new (HandleConnection); Thread connectionListener = new (HandleConnection);
connectionListener.Start(); connectionListener.Start();
this.IsRunning = true; IsRunning = true;
} }
private async void HandleConnection() private async void HandleConnection()
{ {
while (this._keepRunning) while (_keepRunning)
{ {
HttpListenerContext context = await HttpListener.GetContextAsync(); HttpListenerContext context = await HttpListener.GetContextAsync();
HttpListenerRequest request = context.Request; HttpListenerRequest request = context.Request;
@ -47,15 +47,15 @@ internal class GSIServer
this.logger?.Log(LogLevel.Debug, $"Message Content:\n{content}"); this.logger?.Log(LogLevel.Debug, $"Message Content:\n{content}");
OnMessage?.Invoke(content); OnMessage?.Invoke(content);
} }
this.HttpListener.Close(); HttpListener.Close();
this.IsRunning = false; IsRunning = false;
this.logger?.Log(LogLevel.Information, "Stopped GSIServer."); this.logger?.Log(LogLevel.Information, "Stopped GSIServer.");
} }
internal void Dispose() internal void Dispose()
{ {
this.logger?.Log(LogLevel.Information, "Stopping GSIServer."); this.logger?.Log(LogLevel.Information, "Stopping GSIServer.");
this._keepRunning = false; _keepRunning = false;
} }
} }