Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Console shows now
  • Loading branch information
NaysKutzu committed Oct 3, 2023
1 parent 861548c commit cb17f1a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 11 deletions.
60 changes: 59 additions & 1 deletion Forms/FrmServerController.Designer.cs

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

19 changes: 10 additions & 9 deletions Forms/FrmServerController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Newtonsoft.Json;
using Guna.UI2.WinForms;
using Newtonsoft.Json;
using PteroController.PteroConsoleHook;
using PteroController.Pterodactyl;
using System.Net;

namespace PteroController.Forms
Expand All @@ -12,13 +12,18 @@ public FrmServerController(string serverIdentifier)
{
InitializeComponent();
this.serverIdentifier = serverIdentifier;

}
private async void initPteroConsole()
{
try
{
var console = new PteroConsole.NET.PteroConsole();
console.OnServerResourceUpdated += (sender, resource) =>
{
Console.WriteLine($"Stats: {resource.Uptime}, State: {resource.State}");
//cpu.Value = resource.State;
};
console.RequestToken += pteroConsole =>
{
Console.WriteLine("Revoking token");
Expand All @@ -33,7 +38,8 @@ private async void initPteroConsole()
var raw = wc.DownloadString($"{Pterodactyl.User.Info.panel_url}/api/client/servers/{serverIdentifier}/websocket");
var data = JsonConvert.DeserializeObject<WebsocketDataResource>(raw).Data;
await console.Connect(Pterodactyl.User.Info.panel_url, data.Socket, data.Token);
} catch (Exception ex)
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Program.Alert("We are sorry but we can't launch the stats", FrmAlert.enmType.Warning);
Expand Down Expand Up @@ -67,11 +73,6 @@ private void btnservers_Click(object sender, EventArgs e)
x.Show();
this.Hide();
}

private void pblblpanellogo_Click(object sender, EventArgs e)
{

}
}

}
2 changes: 1 addition & 1 deletion PteroController.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
Expand Down

0 comments on commit cb17f1a

Please sign in to comment.