private NetworkAccount Login(out AuntificationState state)
 {
     try
     {
         byte[] buffer = new byte[ClientSocket.ReceiveBufferSize];
         ClientSocket.Receive(buffer);
         string[] serial   = Encoding.UTF8.GetString(buffer).Split('|');
         string   login    = serial[1];
         string   password = serial[2];
         foreach (NetworkAccount account in MainManager.Accounts)
         {
             if (account.Login == login && account.Password == password)
             {
                 state = AuntificationState.Successfully;
                 return(account);
             }
         }
         state = AuntificationState.WrongPassword;
         return(new NetworkAccount());
     }
     catch
     {
         state = AuntificationState.Error;
         return(new NetworkAccount());
     }
 }
Пример #2
0
 private void PasswordChecker(out AuntificationState state)
 {
     try
     {
         byte[] buffer = new byte[ClientSocket.ReceiveBufferSize];
         ClientSocket.Receive(buffer);
         string receivedPassword = Encoding.UTF8.GetString(buffer).Split('|')[1];
         if (receivedPassword == MainManager.ClientChatPassword)
         {
             IsAdmin = false;
             state   = AuntificationState.Successfully;
         }
         else if (receivedPassword == MainManager.AdminChatPassword)
         {
             IsAdmin = true;
             state   = AuntificationState.Successfully;
         }
         else
         {
             state = AuntificationState.WrongPassword;
         }
     }
     catch
     {
         state = AuntificationState.Error;
     }
 }