Skip to content

Commit acda4ca

Browse files
committed
menu entry to display current token
1 parent 46e2784 commit acda4ca

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

ARKBreedingStats/AsbServer/Connection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,5 +275,7 @@ public static string CreateNewToken()
275275
/// Returns the passed token string, or wildcards if the streamer mode is enabled.
276276
/// </summary>
277277
public static string TokenStringForDisplay(string token) => Properties.Settings.Default.StreamerMode ? "****" : token;
278+
279+
public static bool IsCurrentlyListening => _lastCancellationTokenSource != null;
278280
}
279281
}

ARKBreedingStats/Form1.Designer.cs

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ARKBreedingStats/Form1.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3898,13 +3898,36 @@ private void AsbServerStopListening(bool displayMessage = true)
38983898
SetMessageLabelText($"ASB Server listening stopped using token: {Connection.TokenStringForDisplay(Properties.Settings.Default.ExportServerToken)}", MessageBoxIcon.Error);
38993899
}
39003900

3901+
private void currentTokenToolStripMenuItem_Click(object sender, EventArgs e)
3902+
{
3903+
var tokenIsSet = !string.IsNullOrEmpty(Properties.Settings.Default.ExportServerToken);
3904+
string message;
3905+
bool isError;
3906+
if (tokenIsSet)
3907+
{
3908+
message = $"Currently {(Connection.IsCurrentlyListening ? string.Empty : "not ")}listening to the server."
3909+
+ " The current token is " + Environment.NewLine + Connection.TokenStringForDisplay(Properties.Settings.Default.ExportServerToken)
3910+
+ Environment.NewLine + "(token copied to clipboard)";
3911+
3912+
Clipboard.SetText(Properties.Settings.Default.ExportServerToken);
3913+
isError = false;
3914+
}
3915+
else
3916+
{
3917+
message = "Currently no token set. A token is created once you start listening to the server.";
3918+
isError = true;
3919+
}
3920+
3921+
SetMessageLabelText(message, isError ? MessageBoxIcon.Error : MessageBoxIcon.Information,
3922+
clipboardText: Properties.Settings.Default.ExportServerToken, displayPopup: !Properties.Settings.Default.StreamerMode);
3923+
}
3924+
39013925
private void sendExampleCreatureToolStripMenuItem_Click(object sender, EventArgs e)
39023926
{
39033927
// debug function, sends a test creature to the server
39043928
AsbServer.Connection.SendCreatureData(DummyCreatures.CreateCreature(speciesSelector1.SelectedSpecies), Properties.Settings.Default.ExportServerToken);
39053929
}
39063930

39073931
#endregion
3908-
39093932
}
39103933
}

0 commit comments

Comments
 (0)