예제 #1
0
        /// <summary>
        /// Update exist user
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="user">with updated info</param>
        public void UpdateUserInfo(VirtualServerEntity.User user)
        {
            var newInfo = new Dictionary <UserInfo, string>();

            foreach (var it in user.Info)
            {
                newInfo.Add((Murmur.UserInfo)it.Key, it.Value);
            }

            // set user info
            _server.updateRegistration(user.Id, newInfo);

            // update in cache
            if (_entity.Users.ContainsKey(user.Id))
            {
                _entity.Users[user.Id] = user;
            }
            else
            {
                _entity.Users.Add(user.Id, user);
            }
        }
예제 #2
0
        private Agent Add(UUID uuid, Scene scene)
        {
            Agent agent = new Agent(uuid, scene);

            Dictionary <int, User> users = m_server.getUsers();

            foreach (var v in users)
            {
                User user = v.Value;

                if (user.name == agent.name)
                {
                    m_log.DebugFormat("[MurmurVoice] Found previously registered user {0} {1} {2} {3}", user.name, user.userid, user.session, user.channel);

                    if ((user.userid >= 0) && (user.session >= 0))
                    {
                        // Reuse Murmur User
                        m_log.DebugFormat("[MurmurVoice] Reusing previously registered user {0} {1} {2} {3}", user.name, user.userid, user.session, user.channel);

                        agent.userid  = user.userid;
                        agent.session = user.session;
                        agent.channel = user.channel;

                        lock (name_to_agent)
                            name_to_agent[agent.name] = agent;

                        // Handle password changes
                        m_server.updateRegistration(agent.userid, agent.user_info);

                        return(agent);
                    }
                    else
                    {
                        if (user.userid >= 0)
                        {
                            agent.userid = user.userid;

                            lock (name_to_agent)
                                name_to_agent[agent.name] = agent;

                            // Handle password changes
                            m_server.updateRegistration(agent.userid, agent.user_info);

                            return(agent);
                        }
                    }
                    break;
                }
            }

            lock (name_to_agent)
                name_to_agent[agent.name] = agent;

            try
            {
                int r = m_server.registerUser(agent.user_info);
                if (r >= 0)
                {
                    agent.userid = r;
                }
            }
            catch (Murmur.InvalidUserException)
            {
                m_log.Warn("[MurmurVoice] InvalidUserException; continuing to recover later");
            }

            m_log.DebugFormat("[MurmurVoice] Registered {0} (uid {1}) identified by {2}", agent.uuid.ToString(), agent.userid, agent.pass);

            return(agent);
        }