public static void SendMessageInBytes(byte[] data) { if (Stream != null) { BinaryWriter writer = new BinaryWriter(Stream); writer.Write(data); } else if (ServerConnector.ConnectToServer()) { SendMessageInBytes(data); } }
public EnteringWindowViewModel() //EnteringWindow enteringWindow) { //entering = enteringWindow; ServerConnector.ConnectToServer(); if (System.IO.File.Exists(fileName)) { Account account = Account.Deserialize <Account>(fileName); Login = account.Login; Password = GetEncryptPass(account.Password, account.Login); Task.Run(() => { Messenger.Default.Send(Password); EnterButtonIsEnabled = true; }); //IsSavePassword = true; } }
// отправка сообщений public static void SendMessage(string message) { try { if (Stream != null) { BinaryWriter writer = new BinaryWriter(Stream); writer.Write(message + "%"); } else if (ServerConnector.ConnectToServer()) { SendMessage(message); } } catch (Exception ex) { string messageXui = ex.Message; } }
private async void Regisration_Click(object sender, RoutedEventArgs e) { try { if (!IsValid(Email.Text)) { Warning.Text = "Неверный email"; return; } if (Regex.IsMatch(FirstPass.Password, @"[^a-zA-Z0-9]+")) { Warning.Text = "Неверный пароль"; return; } //EnteringWindow entering = (EnteringWindow)Owner; if (!ServerConnector.IsConnectionOpened) { ServerConnector.ConnectToServer(); } if (ServerConnector.IsConnectionOpened) { RequestMethods methods = RequestMethods.GetRequestMethods(); Account account = new Account(RegLogin.Text, Account.GetHashCode(FirstPass.Password), Email.Text); bool result = await methods.RegistrationAsync(account); if (!result) { MessageBox.Show("Такой аккаунт уже существует", "Ошибка", MessageBoxButton.OK); } else { //((EnteringWindowViewModel)Owner).EnterData(account.Login, account.Password); Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); } }
public void CreateRequest <T>(string methodName, T reqObj) { try { if (!ClientAuction.Stream.CanWrite) { if (!ServerConnector.ConnectToServer()) { throw new Exception("Сервер не доступен"); } } string parametr = ClientAuction.SerializeToString(reqObj); Request request = new Request(parametr, methodName); Response = null; ClientAuction.SendMessage(ClientAuction.SerializeToString(request)); } catch (Exception ex) { MessageBox.Show(ex.Message); throw (ex); } }