2015-05-16 11:39:34 -06:00
|
|
|
|
using System;
|
|
|
|
|
using Xwt;
|
2015-06-02 17:39:44 -06:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using TrueCraft.Core;
|
2015-05-16 11:39:34 -06:00
|
|
|
|
|
|
|
|
|
namespace TrueCraft.Launcher
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2015-06-02 17:39:44 -06:00
|
|
|
|
public static LauncherWindow Window { get; set; }
|
|
|
|
|
|
2015-05-16 11:39:34 -06:00
|
|
|
|
[STAThread]
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (RuntimeInfo.IsLinux)
|
|
|
|
|
Application.Initialize(ToolkitType.Gtk);
|
|
|
|
|
else if (RuntimeInfo.IsMacOSX)
|
|
|
|
|
Application.Initialize(ToolkitType.Gtk);
|
|
|
|
|
else if (RuntimeInfo.IsWindows)
|
|
|
|
|
Application.Initialize(ToolkitType.Wpf);
|
2015-06-02 17:52:22 -06:00
|
|
|
|
UserSettings.Local = new UserSettings();
|
|
|
|
|
UserSettings.Local.Load();
|
2015-06-02 17:39:44 -06:00
|
|
|
|
var thread = new Thread(KeepSessionAlive);
|
|
|
|
|
thread.IsBackground = true;
|
|
|
|
|
thread.Priority = ThreadPriority.Lowest;
|
|
|
|
|
Window = new LauncherWindow();
|
|
|
|
|
thread.Start();
|
|
|
|
|
Window.Show();
|
|
|
|
|
Window.Closed += (sender, e) => Application.Exit();
|
2015-05-16 11:39:34 -06:00
|
|
|
|
Application.Run();
|
2015-06-02 17:39:44 -06:00
|
|
|
|
Window.Dispose();
|
|
|
|
|
thread.Abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void KeepSessionAlive()
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(Window.User.SessionId))
|
|
|
|
|
{
|
|
|
|
|
var wc = new WebClient();
|
|
|
|
|
wc.DownloadString(string.Format(TrueCraftUser.AuthServer + "/session?name={0}&session={1}",
|
|
|
|
|
Window.User.Username, Window.User.SessionId));
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(60 * 5 * 1000);
|
|
|
|
|
}
|
2015-05-16 11:39:34 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|