Skip to content

Commit

Permalink
Remote Ping changes
Browse files Browse the repository at this point in the history
Add many new fields to remote pings, add sending data as json, made msg property optional for ping responses
  • Loading branch information
Plenyx committed Oct 25, 2024
1 parent a05e453 commit a285253
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 59 deletions.
11 changes: 8 additions & 3 deletions DpsReport/DpsReportJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ internal sealed class DpsReportJson
/// Time when the log was uploaded to DPSReport
/// </summary>
[JsonProperty("uploadTime")]
internal int UploadTime { get; set; }
internal ulong UploadTime { get; set; }

/// <summary>
/// Total time of the encounter, might be null
/// </summary>
[JsonProperty("encounterTime")]
internal int? EncounterTime { get; set; }
internal ulong? EncounterTime { get; set; }

/// <summary>
/// Log tool used with processing the log on DPSReport
Expand Down Expand Up @@ -100,7 +100,12 @@ internal sealed class DpsReportJson
/// <summary>
/// whether the encounter was in legendary challenge mode
/// </summary>
internal bool LegendaryChallengeMode => ExtraJson?.IsLegendaryCm ?? false;
internal bool LegendaryChallengeMode => (ExtraJson?.IsLegendaryCm ?? false) || (Encounter?.IsLegendaryCm ?? false);

/// <summary>
/// whether the encounter was emboldened
/// </summary>
internal bool Emboldened => (Encounter.Emboldened ?? 0) > 0;

internal List<LogPlayer> GetLogPlayers()
{
Expand Down
8 changes: 7 additions & 1 deletion DpsReport/DpsReportJsonEncounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ internal sealed class DpsReportJsonEncounter
[JsonProperty("isCm")]
internal bool? IsCm { get; set; }

[JsonProperty("isLegendaryCm")]
internal bool? IsLegendaryCm { get; set; }

[JsonProperty("emboldened")]
internal int? Emboldened { get; set; }

[JsonProperty("gw2Build")]
internal int? GameBuild { get; set; }
internal ulong? GameBuild { get; set; }

[JsonProperty("jsonAvailable")]
internal bool? JsonAvailable { get; set; }
Expand Down
11 changes: 10 additions & 1 deletion DpsReport/DpsReportJsonExtraJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ internal sealed class DpsReportJsonExtraJson
[JsonProperty("duration")]
internal string Duration { get; set; }

[JsonProperty("durationMs")]
internal ulong DurationMs { get; set; }

[JsonProperty("success")]
internal bool Succcess { get; set; }

[JsonProperty("triggerID")]
internal int TriggerId { get; set; }

[JsonProperty("fightName")]
internal string FightName { get; set; }

[JsonProperty("gw2Build")]
internal int GameBuild { get; set; }
internal ulong GameBuild { get; set; }

[JsonProperty("fightIcon")]
internal string FightIcon { get; set; }
Expand All @@ -50,6 +56,9 @@ internal sealed class DpsReportJsonExtraJson
[JsonProperty("players")]
internal Player[] Players { get; set; }

[JsonProperty("logErrors")]
internal string[] LogErrors { get; set; }

internal Target PossiblyLastTarget
{
get
Expand Down
13 changes: 10 additions & 3 deletions Forms/FormDiscordWebhooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ await SendLogViaWebhooks(reportJSON.Encounter.Success ?? false,
false,
false,
bossData, players,
jsonContentWvWNone, jsonContentWvWSquad, jsonContentWvWPlayers, jsonContentWvWSquadAndPlayers);
jsonContentWvWNone,
jsonContentWvWSquad,
jsonContentWvWPlayers,
jsonContentWvWSquadAndPlayers);

if (allWebhooks.Count > 0)
{
Expand Down Expand Up @@ -515,8 +518,12 @@ await SendLogViaWebhooks(reportJSON.Encounter.Success ?? false,
reportJSON.Encounter.BossId,
reportJSON.ChallengeMode,
reportJSON.LegendaryChallengeMode,
bossData, players,
jsonContentNone, jsonContentSquad, jsonContentPlayers, jsonContentSquadAndPlayers);
bossData,
players,
jsonContentNone,
jsonContentSquad,
jsonContentPlayers,
jsonContentSquadAndPlayers);

if (allWebhooks.Count > 0)
{
Expand Down
15 changes: 15 additions & 0 deletions Forms/FormEditPing.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Forms/FormEditPing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ internal FormEditPing(FormPings pingLink, int reservedId, bool addNew, PingConfi
{
radioButtonUseNormalField.Checked = true;
}
if (config?.SendDataAsJson ?? true)
{
checkBoxSendDataAsJson.Checked = true;
radioButtonUseNormalField.Enabled = false;
if (radioButtonUseNormalField.Checked)
{
radioButtonNoAuthorization.Checked = true;
}
}
}

private void FormPing_FormClosing(object sender, FormClosingEventArgs e)
Expand Down Expand Up @@ -101,6 +110,7 @@ private void FormPing_FormClosing(object sender, FormClosingEventArgs e)
Url = textBoxURL.Text,
Method = chosenMethod,
Authentication = auth,
SendDataAsJson = checkBoxSendDataAsJson.Enabled,
};
pingLink.listViewPings.Items.Add(new ListViewItem()
{
Expand All @@ -115,6 +125,7 @@ private void FormPing_FormClosing(object sender, FormClosingEventArgs e)
pingLink.AllPings[reservedId].Active = config.Active;
pingLink.AllPings[reservedId].Name = textBoxName.Text;
pingLink.AllPings[reservedId].Url = textBoxURL.Text;
pingLink.AllPings[reservedId].SendDataAsJson = checkBoxSendDataAsJson.Checked;
if (radioButtonMethodPut.Checked)
{
pingLink.AllPings[reservedId].Method = PingMethod.Put;
Expand Down Expand Up @@ -181,6 +192,7 @@ private async void ButtonTestPing_Click(object sender, EventArgs e)
Url = textBoxURL.Text,
Method = chosenMethod,
Authentication = auth,
SendDataAsJson = checkBoxSendDataAsJson.Checked,
};
var result = await tempPing.PingServerAsync(null, null);
if (result)
Expand All @@ -199,5 +211,15 @@ private void RadioButtonNoAuthorization_CheckedChanged(object sender, EventArgs
textBoxAuthName.Enabled = toggle;
textBoxAuthToken.Enabled = toggle;
}

private void CheckBoxSendDataAsJson_CheckedChanged(object sender, EventArgs e)
{
var toggle = checkBoxSendDataAsJson.Checked;
radioButtonUseNormalField.Enabled = !toggle;
if (radioButtonUseNormalField.Checked && toggle)
{
radioButtonNoAuthorization.Checked = true;
}
}
}
}
Loading

0 comments on commit a285253

Please sign in to comment.