Exemplo n.º 1
0
        private async void windowLoaded(object sender, RoutedEventArgs e)
        {
            string hash = null;

            if (File.Exists(HASH_FILE))
            {
                var file = File.ReadAllText(HASH_FILE);
                hash = file;
            }

            cukiAPI.hash = hash;

            // Combobox thing
            addProductType.Items.Clear();
            foreach (string option in productTypes)
            {
                addProductType.Items.Add(option);
            }

            ws = new GenericWebSocket(new Uri(WS_ADDRESS + "/" + hash));
            ws.OnWebSocketConnected += onWSConnected;
            await ws.Connect();

            new WebSocketHandler(ws, this);
        }
Exemplo n.º 2
0
        private async void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            string hash = null;

            if (File.Exists(HASH_FILE))
            {
                var file = File.ReadAllText(HASH_FILE);
                if (await ProgressTrackerAPI.IsHashValid(file))
                {
                    hash = file;
                }
                else
                {
                    File.Delete(HASH_FILE);
                }
            }
            if (hash == null)
            {
                hash = await loginProcess();

                var sw = File.CreateText(HASH_FILE);
                await sw.WriteAsync(hash);

                sw.Close();
            }

            ProgressTrackerAPI.hash = hash;
            loggedInAuthor          = await ProgressTrackerAPI.GetAuthorInfo();

            LoginPanel.Visibility = Visibility.Collapsed;
            MainPanel.Visibility  = Visibility.Visible;

            ws = new GenericWebSocket(new Uri(WS_ADDRESS + "/" + hash));
            ws.OnWebSocketConnected += onWSConnected;
            await ws.Connect();

            new WebSocketHandler(ws, this);
        }
Exemplo n.º 3
0
 public WebSocketHandler(GenericWebSocket WS, MainWindow main)
 {
     ws                    = WS;
     this.main             = main;
     ws.OnMessageReceived += onMessageReceived;
 }