mirror of
https://github.com/BubbaGumpShrump/AutoTrackR2.git
synced 2025-06-18 20:59:05 +00:00
Added unix timestamp to webhandler and consonsole writes.
This commit is contained in:
parent
2dcf2e3571
commit
e28fc836e7
1 changed files with 40 additions and 24 deletions
|
@ -4,6 +4,7 @@ using System.Text;
|
|||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using AutoTrackR2.LogEventHandlers;
|
||||
using System.Globalization;
|
||||
|
||||
namespace AutoTrackR2;
|
||||
|
||||
|
@ -12,16 +13,17 @@ public static class WebHandler
|
|||
class APIKillData
|
||||
{
|
||||
public string? victim_ship { get; set; }
|
||||
public string? victim{ get; set; }
|
||||
public string? enlisted{ get; set; }
|
||||
public string? rsi{ get; set; }
|
||||
public string? weapon{ get; set; }
|
||||
public string? method{ get; set; }
|
||||
public string? loadout_ship{ get; set; }
|
||||
public string? game_version{ get; set; }
|
||||
public string? gamemode{ get; set; }
|
||||
public string? trackr_version{ get; set; }
|
||||
public string? location{ get; set; }
|
||||
public string? victim { get; set; }
|
||||
public string? enlisted { get; set; }
|
||||
public string? rsi { get; set; }
|
||||
public string? weapon { get; set; }
|
||||
public string? method { get; set; }
|
||||
public string? loadout_ship { get; set; }
|
||||
public string? game_version { get; set; }
|
||||
public string? gamemode { get; set; }
|
||||
public string? trackr_version { get; set; }
|
||||
public string? location { get; set; }
|
||||
public long time { get; set; }
|
||||
}
|
||||
|
||||
public static async Task<PlayerData?> GetPlayerData(string enemyPilot)
|
||||
|
@ -80,8 +82,6 @@ public static class WebHandler
|
|||
|
||||
public static async Task SubmitKill(KillData killData)
|
||||
{
|
||||
// int secondSpaceIndex = killData.Enlisted.IndexOf(" ", killData.Enlisted.IndexOf(" ") + 1);
|
||||
// killData.Enlisted = killData.Enlisted.Insert(secondSpaceIndex, ",");
|
||||
var apiKillData = new APIKillData
|
||||
{
|
||||
victim_ship = killData.EnemyShip,
|
||||
|
@ -91,11 +91,11 @@ public static class WebHandler
|
|||
weapon = killData.Weapon,
|
||||
method = killData.Method,
|
||||
gamemode = killData.Mode,
|
||||
// loadout_ship = LocalPlayerData.PlayerShip ?? "Unknown",
|
||||
loadout_ship = killData.Ship,
|
||||
game_version = killData.GameVersion,
|
||||
trackr_version = killData.TrackRver,
|
||||
location = "Unknown"
|
||||
location = "Unknown",
|
||||
time = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
|
||||
};
|
||||
|
||||
if (string.IsNullOrEmpty(apiKillData.rsi))
|
||||
|
@ -108,15 +108,31 @@ public static class WebHandler
|
|||
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + ConfigManager.ApiKey);
|
||||
httpClient.DefaultRequestHeaders.Add("User-Agent", "AutoTrackR2");
|
||||
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
|
||||
|
||||
Console.WriteLine("\n=== Kill Submission Debug Info ===");
|
||||
Console.WriteLine($"API URL: {ConfigManager.ApiUrl}register-kill");
|
||||
Console.WriteLine($"Victim: {apiKillData.victim}");
|
||||
Console.WriteLine($"Victim Ship: {apiKillData.victim_ship}");
|
||||
Console.WriteLine($"Weapon: {apiKillData.weapon}");
|
||||
Console.WriteLine($"Method: {apiKillData.method}");
|
||||
Console.WriteLine($"Game Mode: {apiKillData.gamemode}");
|
||||
Console.WriteLine($"Time (Unix): {apiKillData.time}");
|
||||
Console.WriteLine($"Time (UTC): {DateTimeOffset.UtcNow}");
|
||||
Console.WriteLine("=== End Debug Info ===\n");
|
||||
|
||||
var response = await httpClient.PostAsync(ConfigManager.ApiUrl + "register-kill", new StringContent(jsonData, Encoding.UTF8, "application/json"));
|
||||
if (response.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
Console.WriteLine("Failed to submit kill data: ");
|
||||
Console.WriteLine("Failed to submit kill data:");
|
||||
Console.WriteLine($"Status Code: {response.StatusCode}");
|
||||
Console.WriteLine($"Response: {await response.Content.ReadAsStringAsync()}");
|
||||
Console.WriteLine("Request Data:");
|
||||
Console.WriteLine(jsonData);
|
||||
}
|
||||
else if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
Console.WriteLine("Successfully submitted kill data");
|
||||
Console.WriteLine($"Response: {await response.Content.ReadAsStringAsync()}");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue