From a58859a0d4206c194c9c56212218e2cafc2cc373 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 7 May 2010 21:29:56 -0700 Subject: GridUserService in place. Replaces the contrived concept of storing user's home and position info in the presence service. WARNING: I violated a taboo by deleting 2 migration files and simplifying the original table creation for Presence. This should not cause any problems to anyone, though. Things will work with the new simplified table, as well as with the previous contrived one. If there are any problems, solving them is as easy as dropping the presence table and deleting its row in the migrations table. The presence info only exists during a user's session anyway. BTW, the Meshing files want to be committed too -- EOFs. --- OpenSim/Data/MSSQL/MSSQLGridUserData.cs | 8 +--- OpenSim/Data/MSSQL/MSSQLPresenceData.cs | 72 ++------------------------------- 2 files changed, 5 insertions(+), 75 deletions(-) (limited to 'OpenSim/Data/MSSQL') diff --git a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs index 9993720..1870273 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs @@ -46,11 +46,11 @@ namespace OpenSim.Data.MSSQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public MSSQLGridUserData(string connectionString, string realm) : - base(connectionString, realm, "UserGrid") + base(connectionString, realm, "GridUserStore") { } - public GridUserData GetGridUserData(string userID) + public GridUserData Get(string userID) { GridUserData[] ret = Get("UserID", userID); @@ -60,9 +60,5 @@ namespace OpenSim.Data.MSSQL return ret[0]; } - public bool StoreGridUserData(GridUserData data) - { - return Store(data); - } } } diff --git a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs index 5a4ad3a..e7b3d9c 100644 --- a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs +++ b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs @@ -67,7 +67,7 @@ namespace OpenSim.Data.MSSQL using (SqlCommand cmd = new SqlCommand()) { - cmd.CommandText = String.Format("UPDATE {0} SET Online='false' WHERE [RegionID]=@RegionID", m_Realm); + cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm); cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); cmd.Connection = conn; @@ -76,8 +76,7 @@ namespace OpenSim.Data.MSSQL } } - public bool ReportAgent(UUID sessionID, UUID regionID, string position, - string lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { PresenceData[] pd = Get("SessionID", sessionID.ToString()); if (pd.Length == 0) @@ -88,16 +87,11 @@ namespace OpenSim.Data.MSSQL { cmd.CommandText = String.Format(@"UPDATE {0} SET - [RegionID] = @RegionID, - [Position] = @Position, - [LookAt] = @LookAt, - [Online] = 'true' + [RegionID] = @RegionID WHERE [SessionID] = @SessionID", m_Realm); cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString())); cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@Position", position.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@LookAt", lookAt.ToString())); cmd.Connection = conn; conn.Open(); if (cmd.ExecuteNonQuery() == 0) @@ -106,65 +100,5 @@ namespace OpenSim.Data.MSSQL return true; } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - PresenceData[] pd = Get("UserID", userID); - if (pd.Length == 0) - return false; - - using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand()) - { - - cmd.CommandText = String.Format(@"UPDATE {0} SET - [HomeRegionID] = @HomeRegionID, - [HomePosition] = @HomePosition, - [HomeLookAt] = @HomeLookAt - WHERE [UserID] = @UserID", m_Realm); - - cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID)); - cmd.Parameters.Add(m_database.CreateParameter("@HomeRegionID", regionID.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@HomePosition", position)); - cmd.Parameters.Add(m_database.CreateParameter("@HomeLookAt", lookAt)); - cmd.Connection = conn; - conn.Open(); - if (cmd.ExecuteNonQuery() == 0) - return false; - } - return true; - } - - public void Prune(string userID) - { - using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand()) - { - cmd.CommandText = String.Format("SELECT * from {0} WHERE [UserID] = @UserID", m_Realm); - - cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID)); - cmd.Connection = conn; - conn.Open(); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - List deleteSessions = new List(); - int online = 0; - - while (reader.Read()) - { - if (bool.Parse(reader["Online"].ToString())) - online++; - else - deleteSessions.Add(new UUID(reader["SessionID"].ToString())); - } - - if (online == 0 && deleteSessions.Count > 0) - deleteSessions.RemoveAt(0); - - foreach (UUID s in deleteSessions) - Delete("SessionID", s.ToString()); - } - } - } } } -- cgit v1.1