public async void sendSearchFileRequest(string fName) { ClientSearchReq csr = new ClientSearchReq(fName, currentUser.UserName, currentUser.Password); string jasonStriing = JsonConvert.SerializeObject(csr); byte[] jsonFile = ASCIIEncoding.ASCII.GetBytes(jasonStriing); byte[] jsonFileLength = BitConverter.GetBytes(jsonFile.Length); await ns.WriteAsync(jsonFileLength, 0, jsonFileLength.Length); await ns.WriteAsync(jsonFile, 0, jsonFile.Length); byte[] answer = new byte[1]; await ns.ReadAsync(answer, 0, 1); if (answer[0] == 0) { FileNotFoundLabel.Content = fileNotFound; FileNotFoundLabel.Visibility = Visibility.Visible; return; } else { FileNotFoundLabel.Visibility = Visibility.Hidden; getJsonFile(); } }
private async void appExit(object sender, CancelEventArgs e) { activeFlag = false; try { ClientSearchReq csr = new ClientSearchReq("exit", currentUser.UserName, currentUser.Password); string jasonStriing = JsonConvert.SerializeObject(csr); byte[] jsonFile = ASCIIEncoding.ASCII.GetBytes(jasonStriing); byte[] jsonFileLength = BitConverter.GetBytes(jsonFile.Length); await ns.WriteAsync(jsonFileLength, 0, jsonFileLength.Length); await ns.WriteAsync(jsonFile, 0, jsonFile.Length); ns.Close(); } catch (Exception ed) { Console.WriteLine(ed.ToString()); } }