Telemetry
This commit is contained in:
parent
e010b9d126
commit
78a2479d6c
8 changed files with 446 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Timers;
|
||||
|
|
@ -23,6 +24,7 @@ namespace MosswartMassacre
|
|||
public static bool RemoteCommandsEnabled { get; set; } = false;
|
||||
public static bool HttpServerEnabled { get; set; } = false;
|
||||
public static string CharTag { get; set; } = "";
|
||||
public static bool TelemetryEnabled { get; set; } = false;
|
||||
private static Queue<string> rareMessageQueue = new Queue<string>();
|
||||
private static DateTime _lastSent = DateTime.MinValue;
|
||||
private static readonly Queue<string> _chatQueue = new Queue<string>();
|
||||
|
|
@ -47,6 +49,9 @@ namespace MosswartMassacre
|
|||
|
||||
// Initialize the view (UI)
|
||||
MainView.ViewInit();
|
||||
|
||||
// Enable TLS1.2
|
||||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -59,6 +64,8 @@ namespace MosswartMassacre
|
|||
try
|
||||
{
|
||||
PluginSettings.Save();
|
||||
if (TelemetryEnabled)
|
||||
Telemetry.Stop(); // ensure no dangling timer / HttpClient
|
||||
WriteToChat("Mosswart Massacre is shutting down...");
|
||||
|
||||
// Unsubscribe from chat message event
|
||||
|
|
@ -92,7 +99,10 @@ namespace MosswartMassacre
|
|||
RareMetaEnabled = PluginSettings.Instance.RareMetaEnabled;
|
||||
RemoteCommandsEnabled = PluginSettings.Instance.RemoteCommandsEnabled;
|
||||
HttpServerEnabled = PluginSettings.Instance.HttpServerEnabled;
|
||||
TelemetryEnabled = PluginSettings.Instance.TelemetryEnabled;
|
||||
MainView.SetRareMetaToggleState(RareMetaEnabled);
|
||||
if (TelemetryEnabled)
|
||||
Telemetry.Start();
|
||||
|
||||
WriteToChat("Settings loaded.");
|
||||
}
|
||||
|
|
@ -363,13 +373,42 @@ namespace MosswartMassacre
|
|||
|
||||
switch (subCommand)
|
||||
{
|
||||
case "telemetry":
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (args[1].Equals("enable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
TelemetryEnabled = true;
|
||||
Telemetry.Start();
|
||||
PluginSettings.Instance.TelemetryEnabled = true;
|
||||
WriteToChat("Telemetry streaming ENABLED.");
|
||||
}
|
||||
else if (args[1].Equals("disable", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
TelemetryEnabled = false;
|
||||
Telemetry.Stop();
|
||||
PluginSettings.Instance.TelemetryEnabled = false;
|
||||
WriteToChat("Telemetry streaming DISABLED.");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm telemetry <enable|disable>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm telemetry <enable|disable>");
|
||||
}
|
||||
break;
|
||||
case "help":
|
||||
WriteToChat("Mosswart Massacre Commands:");
|
||||
WriteToChat("/mm report - Show current stats");
|
||||
WriteToChat("/mm reset - Reset all counters");
|
||||
WriteToChat("/mm meta - Toggle rare meta state");
|
||||
WriteToChat("/mm http - http server enable|disable");
|
||||
WriteToChat("/mm remotecommand - Listen to remote commands enable|disable");
|
||||
WriteToChat("/mm report - Show current stats");
|
||||
WriteToChat("/mm loc - Show current location");
|
||||
WriteToChat("/mm telemetry - Telemetry streaming enable|disable"); // NEW
|
||||
WriteToChat("/mm reset - Reset all counters");
|
||||
WriteToChat("/mm meta - Toggle rare meta state");
|
||||
WriteToChat("/mm http - Local http-command server enable|disable");
|
||||
WriteToChat("/mm remotecommand - Listen to allegiance !do/!dot enable|disable");
|
||||
break;
|
||||
|
||||
case "report":
|
||||
|
|
@ -378,10 +417,14 @@ namespace MosswartMassacre
|
|||
WriteToChat(reportMessage);
|
||||
break;
|
||||
|
||||
case "loc":
|
||||
Coordinates here = Coordinates.Me;
|
||||
var pos = Utils.GetPlayerPosition();
|
||||
WriteToChat($"Location: {here} (X={pos.X:F1}, Y={pos.Y:F1}, Z={pos.Z:F1})");
|
||||
break;
|
||||
case "reset":
|
||||
RestartStats();
|
||||
break;
|
||||
|
||||
case "meta":
|
||||
RareMetaEnabled = !RareMetaEnabled;
|
||||
WriteToChat($"Rare meta state is now {(RareMetaEnabled ? "ON" : "OFF")}");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue