Example #1
0
 public void RegisterUser(String name, String ip, String port)
 {
     if (Server.RegisteredUsers.ContainsKey(name)) {
         Server.Message("Duplicated user");
         throw new DuplicateUserException(name);
     }
     else {
         UserView newUser = new UserView(name, ip, int.Parse(port));
         Server.RegisteredUsers.Add(newUser.getName(), newUser);
         Server.Message("User: "******" registered with success!");
     }
 }
Example #2
0
        private bool IsUserInTheList(UserView u, List<UserView> list)
        {
            Console.WriteLine("[Calling] IsUserInTheList");
            bool result = false;

            foreach (UserView uv in list) {
                if (u.getName().Equals(uv.getName())) {
                    Console.WriteLine("User " + u.getName() + " is in the list");
                    result = true; break;
                }
            }

            return result;
        }
Example #3
0
 public bool isEqual(UserView u)
 {
     return this.getName().Equals(u.getName());
 }
Example #4
0
        /// <summary>
        /// Adds a new user to the list of known users and sets its trust value to the default value (1)
        /// </summary>
        /// <param name="name"></param>
        /// <param name="port"></param>
        /// <param name="ip"></param>
        /// 
        public void AddNewKnownUsers(String name, int port, String ip)
        {
            Console.WriteLine("[Calling] AddNewKnownUsers");
            UserView newUser = new UserView(name, ip, port);

            lock (User.KnownUsers) {
                foreach (UserView u in User.KnownUsers.Keys) {
                    if (newUser.getName().Equals(u.getName())) {
                        return;
                    }
                }
                User.KnownUsers.Add(newUser, 1);
            }

            lock (User.KnownUsersTimeout) {
                User.KnownUsersTimeout.Add(newUser.getName(), new JacobsonKarels());
            }
            Console.WriteLine("[AddNewKnownUsers] User " + newUser.getName() + "added successfully");
        }
Example #5
0
 public void addKnownUsers(UserView user, int trustValue)
 {
     knownUsers.Add(user.getName(), trustValue);
 }