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); }
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); }
public WebSocketHandler(GenericWebSocket WS, MainWindow main) { ws = WS; this.main = main; ws.OnMessageReceived += onMessageReceived; }