Exemplo n.º 1
0
 public User Login(string nick, string pass, IPEndPoint endpoint)
 {
     try
     {
         foreach (User user in users)
         {
             if (user.Nick.Equals(nick) && user.Pass.Equals(pass))
             {
                 if (onlineUsers.ContainsKey(user))
                 {
                     Logout(user.Nick);
                 }
                 onlineUsers.Add(user, endpoint);
                 UpdateOnlineUsers?.Invoke(onlineUsers);
                 return(user);
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + " -- " + ex.StackTrace);
         return(null);
     }
 }
Exemplo n.º 2
0
 public void Logout(string nick)
 {
     try
     {
         foreach (User user in onlineUsers.Keys)
         {
             if (user.Nick.Equals(nick))
             {
                 onlineUsers.Remove(user);
                 UpdateOnlineUsers?.Invoke(GetOnlineUsers());
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + " - " + ex.StackTrace);
     }
 }