Ejemplo n.º 1
0
        public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
        {
            UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);

            if (userProfile != null)
            {
                if (userProfile.CurrentAgent.Region == regionID)
                {
                    UserAgentData userAgent = userProfile.CurrentAgent;
                    if (userAgent != null && userAgent.AgentOnline)
                    {
                        userAgent.AgentOnline = false;
                        userAgent.LogoutTime  = Util.UnixTimeSinceEpoch();
                        if (regionID != UUID.Zero)
                        {
                            userAgent.Region = regionID;
                        }
                        userAgent.Handle      = regionHandle;
                        userProfile.LastLogin = userAgent.LogoutTime;

                        m_userDataBaseService.CommitAgent(ref userProfile);

                        handlerLogOffUser = OnLogOffUser;
                        if (handlerLogOffUser != null)
                        {
                            handlerLogOffUser(agentID);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Enqueues a presence update, sending info about user 'talkingAbout' to user 'receiver'.
        /// </summary>
        /// <param name="talkingAbout">We are sending presence information about this user.</param>
        /// <param name="receiver">We are sending the presence update to this user</param>
        private void enqueuePresenceUpdate(UserPresenceData talkingAbout, UserPresenceData receiver)
        {
            UserAgentData p2Handle = m_userDataBaseService.GetUserAgentData(receiver.agentData.AgentID);

            if (p2Handle != null)
            {
                if (receiver.lookupUserRegionYN)
                {
                    // this is incomplete, just filling in one field, but just calling
                    // m_regionModule.GetRegionInfo (again) here isn't a solution.
                    // Maybe we should be treating it as if p2Handle got a null above,
                    // and asynchronously trying to update the regionData again later.
                    receiver.regionData.regionHandle = p2Handle.Handle;
                }
                else
                {
                    receiver.lookupUserRegionYN = true; // TODO Huh?
                }

                PresenceInformer friendlistupdater = new PresenceInformer();
                friendlistupdater.presence1        = talkingAbout;
                friendlistupdater.presence2        = receiver;
                friendlistupdater.OnGetRegionData += m_regionModule.GetRegionInfo;
                friendlistupdater.OnDone          += PresenceUpdateDone;
                WaitCallback cb = new WaitCallback(friendlistupdater.go);
                ThreadPool.QueueUserWorkItem(cb);
            }
            else
            {
                m_log.WarnFormat("[PRESENCE]: no data found for user {0}", receiver.agentData.AgentID);
                // Skip because we can't find any data on the user
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Enqueues a presence update, sending info about user 'talkingAbout' to user 'receiver'.
        /// </summary>
        /// <param name="talkingAbout">We are sending presence information about this user.</param>
        /// <param name="receiver">We are sending the presence update to this user</param>
        private void enqueuePresenceUpdate(UserPresenceData talkingAbout, UserPresenceData receiver)
        {
            UserAgentData p2Handle = m_userDataBaseService.GetUserAgentData(receiver.agentData.AgentID);

            if (p2Handle != null)
            {
                if (receiver.lookupUserRegionYN)
                {
                    receiver.regionData.regionHandle = p2Handle.Handle;
                }
                else
                {
                    receiver.lookupUserRegionYN = true; // TODO Huh?
                }

                PresenceInformer friendlistupdater = new PresenceInformer();
                friendlistupdater.presence1        = talkingAbout;
                friendlistupdater.presence2        = receiver;
                friendlistupdater.OnGetRegionData += m_regionModule.GetRegionInfo;
                friendlistupdater.OnDone          += PresenceUpdateDone;
                WaitCallback cb = new WaitCallback(friendlistupdater.go);
                ThreadPool.QueueUserWorkItem(cb);
            }
            else
            {
                m_log.WarnFormat("no data found for user {0}", receiver.agentData.AgentID);
                // Skip because we can't find any data on the user
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns an agent session by account UUID
        /// </summary>
        /// <param name="uuid">The accounts UUID</param>
        /// <returns>The users session</returns>
        public override UserAgentData GetAgentByUUID(UUID uuid)
        {
            MySQLSuperManager dbm = GetLockedConnection("GetAgentByUUID");

            try
            {
                Dictionary <string, object> param = new Dictionary <string, object>();
                param["?uuid"] = uuid.ToString();

                IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid",
                                                      param);
                IDataReader reader = result.ExecuteReader();

                UserAgentData row = dbm.Manager.readAgentRow(reader);

                reader.Dispose();
                result.Dispose();

                return(row);
            }
            catch (Exception e)
            {
                dbm.Manager.Reconnect();
                m_log.Error(e.ToString());
                return(null);
            }
            finally
            {
                dbm.Release();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new agent
        /// </summary>
        /// <param name="agent">The agent to create</param>
        public override void AddNewUserAgent(UserAgentData agent)
        {
            UUID zero = UUID.Zero;

            if (agent.ProfileID == zero || agent.SessionID == zero)
            {
                return;
            }

            MySQLSuperManager dbm = GetLockedConnection("AddNewUserAgent");

            try
            {
                dbm.Manager.insertAgentRow(agent);
            }
            catch (Exception e)
            {
                dbm.Manager.Reconnect();
                m_log.Error(e.ToString());
            }
            finally
            {
                dbm.Release();
            }
        }
Ejemplo n.º 6
0
        public UserAgentData GetAgentByUUID(UUID user)
        {
            UserAgentData userAgent = null;

            m_agentByProfileUuid.TryGetValue(user, out userAgent);

            return(userAgent);
        }
Ejemplo n.º 7
0
        public void T021_FetchAgentByName()
        {
            String        name3 = fname3 + " " + lname3;
            UserAgentData a2    = db.GetAgentByName(fname2, lname2);
            UserAgentData a3    = db.GetAgentByName(name3);

            Assert.That(user2, Is.EqualTo(a2.ProfileID), "Assert.That(user2,Is.EqualTo(a2.ProfileID))");
            Assert.That(user3, Is.EqualTo(a3.ProfileID), "Assert.That(user3,Is.EqualTo(a3.ProfileID))");
        }
Ejemplo n.º 8
0
        public override bool AddUserAgent(UserAgentData agentdata)
        {
            if (m_localUserServices != null)
            {
                return(m_localUserServices.AddUserAgent(agentdata));
            }

            return(base.AddUserAgent(agentdata));
        }
Ejemplo n.º 9
0
        public UserAgentData GetAgentByName(string fname, string lname)
        {
            UserProfileData userProfile = GetUserByName(fname, lname);
            UserAgentData   userAgent   = null;

            m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent);

            return(userAgent);
        }
Ejemplo n.º 10
0
        public UserAgentData NewAgent(UUID user_profile, UUID agent)
        {
            UserAgentData a = new UserAgentData();

            a.ProfileID       = user_profile;
            a.SessionID       = agent;
            a.SecureSessionID = UUID.Random();
            a.AgentIP         = RandomName();
            return(a);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
        /// </summary>
        /// <param name="profile">The users profile</param>
        /// <param name="request">The users loginrequest</param>
        public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
        {
            //m_log.DebugFormat("[USER MANAGER]: Creating agent {0} {1}", profile.Name, profile.ID);

            UserAgentData agent = new UserAgentData();

            // User connection
            agent.AgentOnline = true;

            if (request.Params.Count > 1)
            {
                if (request.Params[1] != null)
                {
                    IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1];
                    agent.AgentIP   = RemoteIPEndPoint.Address.ToString();
                    agent.AgentPort = (uint)RemoteIPEndPoint.Port;
                }
            }

            // Generate sessions
            RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();

            byte[] randDataS  = new byte[16];
            byte[] randDataSS = new byte[16];
            rand.GetBytes(randDataS);
            rand.GetBytes(randDataSS);

            agent.SecureSessionID = new UUID(randDataSS, 0);
            agent.SessionID       = new UUID(randDataS, 0);

            // Profile UUID
            agent.ProfileID = profile.ID;

            // Current location/position/alignment
            if (profile.CurrentAgent != null)
            {
                agent.Region   = profile.CurrentAgent.Region;
                agent.Handle   = profile.CurrentAgent.Handle;
                agent.Position = profile.CurrentAgent.Position;
                agent.LookAt   = profile.CurrentAgent.LookAt;
            }
            else
            {
                agent.Region   = profile.HomeRegionID;
                agent.Handle   = profile.HomeRegion;
                agent.Position = profile.HomeLocation;
                agent.LookAt   = profile.HomeLookAt;
            }

            // What time did the user login?
            agent.LoginTime  = Util.UnixTimeSinceEpoch();
            agent.LogoutTime = 0;

            profile.CurrentAgent = agent;
        }
Ejemplo n.º 12
0
        public void T011_TestAuthenticatedLoginSuccess()
        {
            TestHelper.InMethod();
            // TODO: Not check inventory part of response yet.
            // TODO: Not checking all of login response thoroughly yet.

            // 1) Test for positive authentication

            Hashtable loginParams = new Hashtable();

            loginParams["first"]  = m_firstName;
            loginParams["last"]   = m_lastName;
            loginParams["passwd"] = "boingboing";

            ArrayList sendParams = new ArrayList();

            sendParams.Add(loginParams);
            sendParams.Add(m_capsEndPoint);                    // is this parameter correct?
            sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct?

            XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams);

            IPAddress      tmpLocal = Util.GetLocalHost();
            IPEndPoint     tmpEnd   = new IPEndPoint(tmpLocal, 80);
            XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd);

            Hashtable responseData = (Hashtable)response.Value;

            UserAgentData uagent = m_userProfileData.CurrentAgent;

            Assert.That(uagent, Is.Not.Null);

            Assert.That(responseData["first_name"], Is.Not.Null);
            Assert.That(responseData["first_name"], Is.EqualTo(m_firstName));
            Assert.That(responseData["last_name"], Is.EqualTo(m_lastName));
            Assert.That(responseData["agent_id"], Is.EqualTo(uagent.ProfileID.ToString()));
            Assert.That(responseData["session_id"], Is.EqualTo(uagent.SessionID.ToString()));
            Assert.That(responseData["secure_session_id"], Is.EqualTo(uagent.SecureSessionID.ToString()));
            ArrayList invlibroot     = (ArrayList)responseData["inventory-lib-root"];
            Hashtable invlibroothash = (Hashtable)invlibroot[0];

            Assert.That(invlibroothash["folder_id"], Is.EqualTo("00000112-000f-0000-0000-000100bba000"));
            Assert.That(
                responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(Int32.MaxValue));
            Assert.That(responseData["message"], Is.EqualTo("Hello folks"));
            Assert.That(responseData["buddy-list"], Is.Empty);
            Assert.That(responseData["start_location"], Is.EqualTo("last"));

            Regex capsSeedPattern
                = new Regex("^http://"
                            + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName)
                            + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$");

            Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True);
        }
Ejemplo n.º 13
0
        public UserAgentData GetAgentByName(string name)
        {
            UserProfileData userProfile = null;

            m_userProfilesByName.TryGetValue(name, out userProfile);
            UserAgentData userAgent = null;

            m_agentByProfileUuid.TryGetValue(userProfile.ID, out userAgent);

            return(userAgent);
        }
Ejemplo n.º 14
0
        public void T022_ExceptionalCases()
        {
            UserAgentData a0 = NewAgent(user4, zero);
            UserAgentData a4 = NewAgent(zero, agent4);

            db.AddNewUserAgent(a0);
            db.AddNewUserAgent(a4);

            Assert.That(db.GetAgentByUUID(user4), Is.Null);
            Assert.That(db.GetAgentByUUID(zero), Is.Null);
        }
Ejemplo n.º 15
0
        public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            // Check IP Endpoint Access
            if (!TrustManager.Instance.IsTrustedPeer(remoteClient))
            {
                return(Util.CreateTrustManagerAccessDeniedResponse());
            }

            XmlRpcResponse response    = new XmlRpcResponse();
            Hashtable      requestData = (Hashtable)request.Params[0];

            if (requestData.Contains("avatar_uuid"))
            {
                UUID guess;

                UUID.TryParse((string)requestData["avatar_uuid"], out guess);

                if (guess == UUID.Zero)
                {
                    return(Util.CreateUnknownUserErrorResponse());
                }

                UserAgentData agentData = m_userDataBaseService.GetUserAgent(guess);

                if (agentData == null)
                {
                    return(Util.CreateUnknownUserErrorResponse());
                }

                Hashtable responseData = new Hashtable();

                responseData["handle"]  = agentData.Handle.ToString();
                responseData["session"] = agentData.SessionID.ToString();
                if (agentData.AgentOnline)
                {
                    responseData["agent_online"] = "TRUE";
                }
                else
                {
                    responseData["agent_online"] = "FALSE";
                }

                response.Value = responseData;
            }
            else
            {
                return(Util.CreateUnknownUserErrorResponse());
            }

            return(response);
        }
Ejemplo n.º 16
0
        public virtual UserAgentData GetAgentByUUID(UUID userId)
        {
            foreach (IUserDataPlugin plugin in m_plugins)
            {
                UserAgentData agent = plugin.GetAgentByUUID(userId);

                if (agent != null)
                {
                    return(agent);
                }
            }

            return(null);
        }
Ejemplo n.º 17
0
        public virtual UserAgentData GetAgentData(UUID uuid)
        {
            m_log.DebugFormat("[USERSTORAGE]: GetAgentData plugin request for {0}", uuid);
            foreach (IUserDataPlugin plugin in m_plugins)
            {
                UserAgentData agent = plugin.GetAgentByUUID(uuid);
                if (agent != null)
                {
                    return(agent);
                }
            }

            return(null);
        }
Ejemplo n.º 18
0
        public void T023_AgentPersistency()
        {
            UUID    user          = user4;
            UUID    agent         = agent4;
            UUID    secureagent   = UUID.Random();
            string  agentip       = RandomName();
            uint    agentport     = (uint)random.Next();
            bool    agentonline   = (random.NextDouble() > 0.5);
            int     logintime     = random.Next();
            int     logouttime    = random.Next();
            UUID    regionid      = UUID.Random();
            ulong   regionhandle  = (ulong)random.Next();
            Vector3 currentpos    = new Vector3((float)Math.Round(random.NextDouble(), 5), (float)Math.Round(random.NextDouble(), 5), (float)Math.Round(random.NextDouble(), 5));
            Vector3 currentlookat = new Vector3((float)Math.Round(random.NextDouble(), 5), (float)Math.Round(random.NextDouble(), 5), (float)Math.Round(random.NextDouble(), 5));
            UUID    orgregionid   = UUID.Random();

            UserAgentData a = new UserAgentData();

            a.ProfileID       = user;
            a.SessionID       = agent;
            a.SecureSessionID = secureagent;
            a.AgentIP         = agentip;
            a.AgentPort       = agentport;
            a.AgentOnline     = agentonline;
            a.LoginTime       = logintime;
            a.LogoutTime      = logouttime;
            a.Region          = regionid;
            a.Handle          = regionhandle;
            a.Position        = currentpos;
            a.LookAt          = currentlookat;
            a.InitialRegion   = orgregionid;

            db.AddNewUserAgent(a);

            UserAgentData a1 = db.GetAgentByUUID(user4);

            Assert.That(user, Is.EqualTo(a1.ProfileID), "Assert.That(user,Is.EqualTo(a1.ProfileID))");
            Assert.That(agent, Is.EqualTo(a1.SessionID), "Assert.That(agent,Is.EqualTo(a1.SessionID))");
            Assert.That(secureagent, Is.EqualTo(a1.SecureSessionID), "Assert.That(secureagent,Is.EqualTo(a1.SecureSessionID))");
            Assert.That(agentip, Is.EqualTo(a1.AgentIP), "Assert.That(agentip,Is.EqualTo(a1.AgentIP))");
            Assert.That(agentport, Is.EqualTo(a1.AgentPort), "Assert.That(agentport,Is.EqualTo(a1.AgentPort))");
            Assert.That(agentonline, Is.EqualTo(a1.AgentOnline), "Assert.That(agentonline,Is.EqualTo(a1.AgentOnline))");
            Assert.That(logintime, Is.EqualTo(a1.LoginTime), "Assert.That(logintime,Is.EqualTo(a1.LoginTime))");
            Assert.That(logouttime, Is.EqualTo(a1.LogoutTime), "Assert.That(logouttime,Is.EqualTo(a1.LogoutTime))");
            Assert.That(regionid, Is.EqualTo(a1.Region), "Assert.That(regionid,Is.EqualTo(a1.Region))");
            Assert.That(regionhandle, Is.EqualTo(a1.Handle), "Assert.That(regionhandle,Is.EqualTo(a1.Handle))");
            Assert.That(currentpos, Is.EqualTo(a1.Position), "Assert.That(currentpos,Is.EqualTo(a1.Position))");
            Assert.That(currentlookat, Is.EqualTo(a1.LookAt), "Assert.That(currentlookat,Is.EqualTo(a1.LookAt))");
        }
Ejemplo n.º 19
0
        public virtual UserAgentData GetAgentData(UUID uuid)
        {
            // m_log.DebugFormat("[USERSTORAGE]: GetAgentData plugin request for {0}", uuid);
            foreach (IUserDataPlugin plugin in m_plugins)
            {
                UserAgentData agent = plugin.GetAgentByUUID(uuid);
                if (agent != null)
                {
                    // Whatever plugin returns an agent data structure, ensure the UUID is filled in.
                    agent.ProfileID = uuid;
                    return(agent);
                }
            }

            return(null);
        }
Ejemplo n.º 20
0
//        public Uri GetUserUri(UserProfileData userProfile)
//        {
//            throw new NotImplementedException();
//        }

        public virtual UserAgentData GetAgentByUUID(UUID userId)
        {
            try
            {
                Hashtable param = new Hashtable();
                param["avatar_uuid"] = userId.ToString();
                IList parameters = new ArrayList();
                parameters.Add(param);
                XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters);

                XmlRpcResponse resp     = req.Send(GetUserServerURL(userId), 6000);
                Hashtable      respData = (Hashtable)resp.Value;
                if (respData.Contains("error_type"))
                {
                    //m_log.Warn("[GRID]: " +
                    //           "Error sent by user server when trying to get agent: (" +
                    //           (string) respData["error_type"] +
                    //           "): " + (string)respData["error_desc"]);
                    return(null);
                }
                UUID sessionid = UUID.Zero;

                UserAgentData userAgent = new UserAgentData();
                userAgent.Handle = Convert.ToUInt64((string)respData["handle"]);
                UUID.TryParse((string)respData["sessionid"], out sessionid);
                userAgent.SessionID = sessionid;

                if ((string)respData["agent_online"] == "TRUE")
                {
                    userAgent.AgentOnline = true;
                }
                else
                {
                    userAgent.AgentOnline = false;
                }

                return(userAgent);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[OGS1 USER SERVICES]: Error when trying to fetch agent data by uuid from remote user server: {0}",
                    e);
            }

            return(null);
        }
Ejemplo n.º 21
0
        private void AttachUserAgentToUserProfile(Session session, UUID sessionId, UUID sceneId, UserProfileData userProfile)
        {
            //Scene scene = m_scenes[sceneId];
            CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
            IUserService          userService  = (IUserService)commsManager.UserService;

            UserAgentData agent = new UserAgentData();

            // User connection
            agent.AgentOnline = true;
            agent.AgentIP     = session.RemoteEndPoint.Address.ToString();
            agent.AgentPort   = (uint)session.RemoteEndPoint.Port;

            agent.SecureSessionID = UUID.Random();
            agent.SessionID       = sessionId;

            // Profile UUID
            agent.ProfileID = userProfile.ID;

            // Current location/position/alignment
            if (userProfile.CurrentAgent != null)
            {
                agent.Region   = userProfile.CurrentAgent.Region;
                agent.Handle   = userProfile.CurrentAgent.Handle;
                agent.Position = userProfile.CurrentAgent.Position;
                agent.LookAt   = userProfile.CurrentAgent.LookAt;
            }
            else
            {
                agent.Region   = userProfile.HomeRegionID;
                agent.Handle   = userProfile.HomeRegion;
                agent.Position = userProfile.HomeLocation;
                agent.LookAt   = userProfile.HomeLookAt;
            }

            // What time did the user login?
            agent.LoginTime  = Util.UnixTimeSinceEpoch();
            agent.LogoutTime = 0;

            userProfile.CurrentAgent = agent;


            userService.UpdateUserProfile(userProfile);
            //userService.CommitAgent(ref userProfile);
        }
Ejemplo n.º 22
0
        override public UserProfileData GetUserByUUID(UUID uuid)
        {
            UserProfileData user;

            m_log.InfoFormat("[NHIBERNATE] GetUserByUUID: {0} ", uuid);

            user = (UserProfileData)manager.Get(typeof(UserProfileData), uuid);
            if (user != null)
            {
                UserAgentData agent = GetAgentByUUID(uuid);
                if (agent != null)
                {
                    user.CurrentAgent = agent;
                }
            }

            return(user);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Reads an agent row from a database reader
        /// </summary>
        /// <param name="reader">An active database reader</param>
        /// <returns>A user session agent</returns>
        public UserAgentData readAgentRow(IDataReader reader)
        {
            UserAgentData retval = new UserAgentData();

            if (reader.Read())
            {
                // Agent IDs
                UUID tmp;
                if (!UUID.TryParse(Convert.ToString(reader["UUID"]), out tmp))
                {
                    return(null);
                }
                retval.ProfileID = tmp;

                UUID.TryParse(Convert.ToString(reader["sessionID"]), out tmp);
                retval.SessionID = tmp;

                UUID.TryParse(Convert.ToString(reader["secureSessionID"]), out tmp);
                retval.SecureSessionID = tmp;

                // Agent Who?
                retval.AgentIP     = (string)reader["agentIP"];
                retval.AgentPort   = Convert.ToUInt32(reader["agentPort"].ToString());
                retval.AgentOnline = Convert.ToBoolean(Convert.ToInt16(reader["agentOnline"].ToString()));

                // Login/Logout times (UNIX Epoch)
                retval.LoginTime  = Convert.ToInt32(reader["loginTime"].ToString());
                retval.LogoutTime = Convert.ToInt32(reader["logoutTime"].ToString());

                // Current position
                retval.Region = new UUID(Convert.ToString(reader["currentRegion"]));
                retval.Handle = Convert.ToUInt64(reader["currentHandle"].ToString());
                Vector3 tmp_v;
                Vector3.TryParse((string)reader["currentPos"], out tmp_v);
                retval.Position = tmp_v;
                Vector3.TryParse((string)reader["currentLookAt"], out tmp_v);
                retval.LookAt = tmp_v;
            }
            else
            {
                return(null);
            }
            return(retval);
        }
Ejemplo n.º 24
0
        public override Dictionary <UUID, FriendRegionInfo> GetFriendRegionInfos(List <UUID> friendsIds)
        {
            Dictionary <UUID, FriendRegionInfo> friendRegionInfos = new Dictionary <UUID, FriendRegionInfo>();

            foreach (UUID friendId in friendsIds)
            {
                UserAgentData agent = GetAgentByUUID(friendId);
                if (agent != null)
                {
                    FriendRegionInfo fri = new FriendRegionInfo();
                    fri.isOnline     = agent.AgentOnline;
                    fri.regionHandle = agent.Handle;

                    friendRegionInfos[friendId] = fri;
                }
            }

            return(friendRegionInfos);
        }
Ejemplo n.º 25
0
        public bool AddNewUserAgent(UserAgentData agent)
        {
            m_log.DebugFormat("[USERSTORAGE]: AddNewUserAgent plugin request for {0}", agent.ProfileID);
            bool result = false;

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.AddNewUserAgent(agent);
                    result = true;
                }
                catch (Exception e)
                {
                    m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")");
                }
            }
            return(result);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Add an agent using data plugins.
        /// </summary>
        /// <param name="agentdata">The agent data to be added</param>
        /// <returns>
        /// true if at least one plugin added the user agent.  false if no plugin successfully added the agent
        /// </returns>
        public virtual bool AddUserAgent(UserAgentData agentdata)
        {
            bool result = false;

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.AddNewUserAgent(agentdata);
                    result = true;
                }
                catch (Exception e)
                {
                    m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")");
                }
            }

            return(result);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Creates a new agent and inserts it into the database
        /// </summary>
        /// <param name="agentdata">The agent data to be inserted</param>
        /// <returns>Success?</returns>
        public bool insertAgentRow(UserAgentData agentdata)
        {
            string sql = String.Empty;

            sql += "REPLACE INTO ";
            sql += "agents (UUID, sessionID, secureSessionID, agentIP, agentPort, agentOnline, loginTime, logoutTime, currentRegion, currentHandle, currentPos, currentLookAt) VALUES ";
            sql += "(?UUID, ?sessionID, ?secureSessionID, ?agentIP, ?agentPort, ?agentOnline, ?loginTime, ?logoutTime, ?currentRegion, ?currentHandle, ?currentPos, ?currentLookAt);";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["?UUID"]            = agentdata.ProfileID.ToString();
            parameters["?sessionID"]       = agentdata.SessionID.ToString();
            parameters["?secureSessionID"] = agentdata.SecureSessionID.ToString();
            parameters["?agentIP"]         = agentdata.AgentIP.ToString();
            parameters["?agentPort"]       = agentdata.AgentPort.ToString();
            parameters["?agentOnline"]     = (agentdata.AgentOnline == true) ? "1" : "0";
            parameters["?loginTime"]       = agentdata.LoginTime.ToString();
            parameters["?logoutTime"]      = agentdata.LogoutTime.ToString();
            parameters["?currentRegion"]   = agentdata.Region.ToString();
            parameters["?currentHandle"]   = agentdata.Handle.ToString();
            parameters["?currentPos"]      = "<" + (agentdata.Position.X).ToString().Replace(",", ".") + "," + (agentdata.Position.Y).ToString().Replace(",", ".") + "," + (agentdata.Position.Z).ToString().Replace(",", ".") + ">";
            parameters["?currentLookAt"]   = "<" + (agentdata.LookAt.X).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Y).ToString().Replace(",", ".") + "," + (agentdata.LookAt.Z).ToString().Replace(",", ".") + ">";

            bool returnval = false;

            try
            {
                IDbCommand result = Query(sql, parameters);

                if (result.ExecuteNonQuery() > 0)
                {
                    returnval = true;
                }
                result.Dispose();
            }
            catch (Exception e)
            {
                m_log.Error(e.ToString());
                return(false);
            }

            return(returnval);
        }
Ejemplo n.º 28
0
        public void T020_CreateAgent()
        {
            UserAgentData a1 = NewAgent(user1, agent1);
            UserAgentData a2 = NewAgent(user2, agent2);
            UserAgentData a3 = NewAgent(user3, agent3);

            db.AddNewUserAgent(a1);
            db.AddNewUserAgent(a2);
            db.AddNewUserAgent(a3);
            UserAgentData a1a = db.GetAgentByUUID(user1);
            UserAgentData a2a = db.GetAgentByUUID(user2);
            UserAgentData a3a = db.GetAgentByUUID(user3);

            Assert.That(agent1, Is.EqualTo(a1a.SessionID), "Assert.That(agent1,Is.EqualTo(a1a.SessionID))");
            Assert.That(user1, Is.EqualTo(a1a.ProfileID), "Assert.That(user1,Is.EqualTo(a1a.ProfileID))");
            Assert.That(agent2, Is.EqualTo(a2a.SessionID), "Assert.That(agent2,Is.EqualTo(a2a.SessionID))");
            Assert.That(user2, Is.EqualTo(a2a.ProfileID), "Assert.That(user2,Is.EqualTo(a2a.ProfileID))");
            Assert.That(agent3, Is.EqualTo(a3a.SessionID), "Assert.That(agent3,Is.EqualTo(a3a.SessionID))");
            Assert.That(user3, Is.EqualTo(a3a.ProfileID), "Assert.That(user3,Is.EqualTo(a3a.ProfileID))");
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Loads a user agent by name (not called directly)
        /// </summary>
        /// <param name="name">The agent's name</param>
        /// <returns>A user agent</returns>
        public UserAgentData GetUserAgentData(string name)
        {
            m_log.DebugFormat("[USERSTORAGE]: GetUserAgentData plugin request for {0}", name);
            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    UserAgentData result = plugin.GetAgentByName(name);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                catch (Exception e)
                {
                    m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")");
                }
            }

            return(null);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Loads a user agent by name (not called directly)
        /// </summary>
        /// <param name="fname">The agent's firstname</param>
        /// <param name="lname">The agent's lastname</param>
        /// <returns>A user agent</returns>
        public UserAgentData GetUserAgent(string fname, string lname)
        {
            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    UserAgentData result = plugin.GetAgentByName(fname, lname);

                    if (result != null)
                    {
                        return(result);
                    }
                }
                catch (Exception e)
                {
                    m_log.Error("[USERSTORAGE]: Unable to find user via " + plugin.Name + "(" + e.ToString() + ")");
                }
            }

            return(null);
        }
Ejemplo n.º 31
0
 public bool AddNewUserAgent(UserAgentData agent)
 {
     m_log.DebugFormat("[USERSTORAGE]: AddNewUserAgent plugin request for {0}", agent.ProfileID);
     bool result = false;
     foreach (IUserDataPlugin plugin in m_plugins)
     {
         try
         {
             plugin.AddNewUserAgent(agent);
             result = true;
         }
         catch (Exception e)
         {
             m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")");
         }
     }
     return result;
 }
 /// <summary>
 /// Add an agent using data plugins.
 /// </summary>
 /// <param name="agentdata">The agent data to be added</param>
 /// <returns>
 /// true if at least one plugin added the user agent.  false if no plugin successfully added the agent
 /// </returns>
 public virtual bool AddUserAgent(UserAgentData agentdata)
 {
     bool result = false;
     
     foreach (IUserDataPlugin plugin in m_plugins)
     {
         try
         {
             plugin.AddNewUserAgent(agentdata);
             result = true;
         }
         catch (Exception e)
         {
             m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")");
         }
     }
     
     return result;
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Add an agent using data plugins.
        /// </summary>
        /// <param name="agentdata">The agent data to be added</param>
        /// <returns>
        /// true if at least one plugin added the user agent.  false if no plugin successfully added the agent
        /// </returns>
        public virtual bool AddUserAgent(UserAgentData agentdata)
        {
            bool result = false;

            lock (_cachedAgentData)
            {
                UUID userId = agentdata.ProfileID;

                TimestampedItem<UserAgentData> timedItem = null;
                if (_cachedAgentData.TryGetValue(userId, out timedItem))
                {
//                    if (m_isUserServer && (timedItem.Item.SecureSessionID != agentdata.SecureSessionID))
//                        m_log.WarnFormat("[USER CACHE]: AddUserAgent: Removing old agent data for {0} SSID={1}", userId, timedItem.Item.SecureSessionID);
                    _cachedAgentData.Remove(userId);
                }

                // Must also add the updated record to the cache, inside the lock, or risk
                // a race condition with other threads refreshing the cache from the database 
                // before plugin.AddNewUserAgent below has finished committing the change.
                _cachedAgentData.Add(userId, new TimestampedItem<UserAgentData>(agentdata));
            }

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
//                    if (m_isUserServer) m_log.WarnFormat("[USER CACHE]: AddUserAgent: Adding agent data for {0} SSID={1}", agentdata.ProfileID, agentdata.SecureSessionID);
                    plugin.AddNewUserAgent(agentdata);
                    result = true;
                }
                catch (Exception e)
                {
                    m_log.Error("[USERSTORAGE]: Unable to add agent via " + plugin.Name + "(" + e.ToString() + ")");
                }
            }
            
            return result;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Creates and initializes a new user agent - make sure to use CommitAgent when done to submit to the DB
        /// This method is only ever invoked by the User server (not regions).
        /// </summary>
        /// <param name="profile">The users profile</param>
        /// <param name="request">The users loginrequest</param>
        public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
        {
            // m_log.DebugFormat("[USER CACHE]: Creating agent {0} {1}", profile.Name, profile.ID);
            
            UserAgentData agent = new UserAgentData();

            // User connection
            agent.AgentOnline = true;

            if (request.Params.Count > 1)
            {
                if (request.Params[1] != null)
                {
                    IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1];
                    agent.AgentIP = RemoteIPEndPoint.Address.ToString();
                    agent.AgentPort = (uint)RemoteIPEndPoint.Port;
                }
            }

            // Generate sessions
            RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
            byte[] randDataS = new byte[16];
            byte[] randDataSS = new byte[16];
            rand.GetBytes(randDataS);
            rand.GetBytes(randDataSS);

            agent.SecureSessionID = new UUID(randDataSS, 0);
            agent.SessionID = new UUID(randDataS, 0);

            // Profile UUID
            agent.ProfileID = profile.ID;

            // Current location/position/alignment
            if (profile.CurrentAgent != null)
            {
                m_log.InfoFormat("[USER CACHE]: Creating agent {0} {1} at {2} {3} was {4} {5}", profile.Name, profile.ID, Util.RegionHandleToLocationString(profile.CurrentAgent.Handle), profile.CurrentAgent.Position, Util.RegionHandleToLocationString(agent.Handle), agent.Position);
                agent.Region = profile.CurrentAgent.Region;
                agent.Handle = profile.CurrentAgent.Handle;
                agent.Position = profile.CurrentAgent.Position;
                agent.LookAt = profile.CurrentAgent.LookAt;
            }
            else
            {
                m_log.InfoFormat("[USER CACHE]: Creating agent {0} {1} at HOME {2} {3} was {4} {5}", profile.Name, profile.ID, Util.RegionHandleToLocationString(profile.HomeRegion), profile.HomeLocation, Util.RegionHandleToLocationString(agent.Handle), agent.Position);
                agent.Region = profile.HomeRegionID;
                agent.Handle = profile.HomeRegion;
                agent.Position = profile.HomeLocation;
                agent.LookAt = profile.HomeLookAt;
            }

            // What time did the user login?
            agent.LoginTime = Util.UnixTimeSinceEpoch();
            agent.LogoutTime = 0;

            // if (m_isUserServer)
            //     m_log.WarnFormat("[USER CACHE]: Creating new agent data for {0} SSID={1} at {2} {3}", agent.ProfileID, agent.SecureSessionID, Util.RegionHandleToLocationString(agent.Handle), agent.Position); 

            profile.CurrentAgent = agent;
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Add an agent using data plugins.
        /// </summary>
        /// <param name="agent">The agent data to be added</param>
        /// <returns>
        /// true if at least one plugin added the user agent.  false if no plugin successfully added the agent
        /// </returns>
        public virtual bool AddUserAgent(UserAgentData agent)
        {
            lock (m_agentDataByUUID)
            {
                UUID uuid = agent.ProfileID;

                TimestampedItem<UserAgentData> timedItem = null;
                if (m_agentDataByUUID.TryGetValue(uuid, out timedItem))
                    m_agentDataByUUID.Remove(uuid);

                // Must also add the updated record to the cache, inside the lock, or risk
                // a race condition with other threads refreshing the cache from the database 
                // before plugin.AddNewUserAgent below has finished committing the change.
                m_agentDataByUUID.Add(uuid, new TimestampedItem<UserAgentData>(agent));
            }

            return m_storage.AddNewUserAgent(agent);
        }
 public void AddNewUserAgent(UserAgentData agent) {}
Ejemplo n.º 37
0
        public void CreateAgent(UserProfileData profile, OSD request)
        {
            //m_log.DebugFormat("[USER CACHE]: Creating agent {0} {1}", profile.Name, profile.ID);
            
            UserAgentData agent = new UserAgentData();

            // User connection
            agent.AgentOnline = true;

            //if (request.Params.Count > 1)
            //{
            //    IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1];
            //    agent.AgentIP = RemoteIPEndPoint.Address.ToString();
            //    agent.AgentPort = (uint)RemoteIPEndPoint.Port;
            //}

            // Generate sessions
            RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
            byte[] randDataS = new byte[16];
            byte[] randDataSS = new byte[16];
            rand.GetBytes(randDataS);
            rand.GetBytes(randDataSS);

            agent.SecureSessionID = new UUID(randDataSS, 0);
            agent.SessionID = new UUID(randDataS, 0);

            // Profile UUID
            agent.ProfileID = profile.ID;

            // Current location/position/alignment
            if (profile.CurrentAgent != null)
            {
                agent.Region = profile.CurrentAgent.Region;
                agent.Handle = profile.CurrentAgent.Handle;
                agent.Position = profile.CurrentAgent.Position;
                agent.LookAt = profile.CurrentAgent.LookAt;
            }
            else
            {
                agent.Region = profile.HomeRegionID;
                agent.Handle = profile.HomeRegion;
                agent.Position = profile.HomeLocation;
                agent.LookAt = profile.HomeLookAt;
            }

            // What time did the user login?
            agent.LoginTime = Util.UnixTimeSinceEpoch();
            agent.LogoutTime = 0;

            profile.CurrentAgent = agent;
        }
Ejemplo n.º 38
0
 private void ReplaceAgentData(UserAgentData agent)
 {
     lock (m_agentDataByUUID)
     {
         TimestampedItem<UserAgentData> item;
         if (m_agentDataByUUID.TryGetValue(agent.ProfileID, out item))
         {
             m_agentDataByUUID.Remove(agent.ProfileID);
         }
         m_agentDataByUUID.Add(agent.ProfileID, new TimestampedItem<UserAgentData>(agent));
     }
 }