using System;
using System.Collections;
using System.Diagnostics;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BepInExGrafana")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7cb7644b154f58916eabb5ecdb0f4a640f0b825e")]
[assembly: AssemblyProduct("BepInExGrafana")]
[assembly: AssemblyTitle("BepInExGrafana")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace GrafanaPostMod
{
[BepInPlugin("com.pengucc.grafanapostmod", "Grafana Post Mod", "1.0.0")]
public class GrafanaPostMod : BaseUnityPlugin
{
private static readonly HttpClient httpClient = new HttpClient();
private float postRequestInterval = 15f;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Grafana Post Mod is initializing...");
((MonoBehaviour)this).StartCoroutine(PostRequestCoroutine());
}
private IEnumerator PostRequestCoroutine()
{
while (true)
{
yield return (object)new WaitForSeconds(postRequestInterval);
Task.Run(async delegate
{
await SendPostRequest();
});
}
}
private async Task SendPostRequest()
{
try
{
string url = "http://5.161.51.188:5002/api/leplayers";
int playerCount = 1;
string jsonData = $"{{ \"player_count\": {playerCount} }}";
StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = await httpClient.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
((BaseUnityPlugin)this).Logger.LogInfo((object)("Successfully sent POST request. Response: " + responseBody));
}
catch (Exception ex2)
{
Exception ex = ex2;
((BaseUnityPlugin)this).Logger.LogError((object)("Error sending POST request: " + ex.Message));
}
}
}
}