Exemplo n.º 1
0
        internal static void UploadGame(string gameData)
        {
            Functions.DebugMessage("Uploading GameData...");
            new Thread(() =>
            {
                for (int i = 0; i < 10; i++)
                {
                    try
                    {
                        using (WebClient client = new WebClient())
                        {
                            byte[] response = client.UploadValues($"http://api.{AppData.initalize.Host}/game/upload/", new NameValueCollection {
                                { "gameData", gameData }
                            });
                            ServerOutput.TokensOutput result = JsonConvert.DeserializeObject <ServerOutput.TokensOutput>(Encoding.UTF8.GetString(response));

                            if (result.success)
                            {
                                ScreenCaptureHandler.trayMenu.ChangeTray("Previous game successfully uploaded", Resources.Icon_Active);
                                Functions.DebugMessage("Successfully uploaded game");
                                break;
                            }
                            Functions.DebugMessage("Failed to upload game, message: " + result.message);
                        }
                    }
                    catch { }
                    Thread.Sleep(1000);
                }
            }).Start();
        }
Exemplo n.º 2
0
        internal static void VerifyToken()
        {
            try
            {
                using (WebClient client = new WebClient())
                {
                    byte[] response = client.UploadValues($"http://api.{AppData.initalize.Host}/verify-account/", new NameValueCollection
                    {
                        { "privateToken", AppData.settings.privateToken }
                    });
                    ServerOutput.TokensOutput result = JsonConvert.DeserializeObject <ServerOutput.TokensOutput>(Encoding.UTF8.GetString(response));

                    if (result.success)
                    {
                        AppData.settings.privateToken = result.privateToken;

                        if (result.publicToken.Length > 0)
                        {
                            AppData.settings.publicToken = result.publicToken;
                        }
                        ScreenCaptureHandler.captureScreen = true;
                        ScreenCaptureHandler.trayMenu.contextMenu.MenuItems[1].Text = "Logout";
                    }
                    else
                    {
                        Program.autenticationForm = new AuthenticationForm();
                        Program.autenticationForm.Show();
                    }
                }
            }
            catch
            {
                Program.autenticationForm = new AuthenticationForm();
                Program.autenticationForm.Show();
            }
        }