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/MySQL/MySQLGridUserData.cs | 9 ++-- OpenSim/Data/MySQL/MySQLPresenceData.cs | 66 ++------------------------- OpenSim/Data/MySQL/Resources/001_Presence.sql | 10 ++-- OpenSim/Data/MySQL/Resources/002_Presence.sql | 7 --- OpenSim/Data/MySQL/Resources/003_Presence.sql | 6 --- 5 files changed, 10 insertions(+), 88 deletions(-) delete mode 100644 OpenSim/Data/MySQL/Resources/002_Presence.sql delete mode 100644 OpenSim/Data/MySQL/Resources/003_Presence.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index df29ecd..a9ce94d 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -44,9 +44,9 @@ namespace OpenSim.Data.MySQL { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "UserGrid") {} + public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} - public GridUserData GetGridUserData(string userID) + public GridUserData Get(string userID) { GridUserData[] ret = Get("UserID", userID); @@ -56,9 +56,6 @@ namespace OpenSim.Data.MySQL return ret[0]; } - public bool StoreGridUserData(GridUserData data) - { - return Store(data); - } + } } \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 143dbe3..71caa1a 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -65,15 +65,14 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(); - 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.AddWithValue("?RegionID", regionID.ToString()); ExecuteNonQuery(cmd); } - 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) @@ -81,12 +80,10 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm); + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?Position", position.ToString()); - cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString()); if (ExecuteNonQuery(cmd) == 0) return false; @@ -94,62 +91,5 @@ namespace OpenSim.Data.MySQL return true; } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - PresenceData[] pd = Get("UserID", userID); - if (pd.Length == 0) - return false; - - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm); - - cmd.Parameters.AddWithValue("?UserID", userID); - cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?HomePosition", position); - cmd.Parameters.AddWithValue("?HomeLookAt", lookAt); - - if (ExecuteNonQuery(cmd) == 0) - return false; - - return true; - } - - public void Prune(string userID) - { - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); - - cmd.Parameters.AddWithValue("?UserID", userID); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - cmd.Connection = dbcon; - - using (IDataReader 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())); - } - - // Leave one session behind so that we can pick up details such as home location - if (online == 0 && deleteSessions.Count > 0) - deleteSessions.RemoveAt(0); - - foreach (UUID s in deleteSessions) - Delete("SessionID", s.ToString()); - } - } - } } } diff --git a/OpenSim/Data/MySQL/Resources/001_Presence.sql b/OpenSim/Data/MySQL/Resources/001_Presence.sql index b8abaf7..84fa057 100644 --- a/OpenSim/Data/MySQL/Resources/001_Presence.sql +++ b/OpenSim/Data/MySQL/Resources/001_Presence.sql @@ -4,12 +4,10 @@ CREATE TABLE `Presence` ( `UserID` VARCHAR(255) NOT NULL, `RegionID` CHAR(36) NOT NULL, `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `Online` CHAR(5) NOT NULL DEFAULT 'false', - `Login` CHAR(16) NOT NULL DEFAULT '0', - `Logout` CHAR(16) NOT NULL DEFAULT '0', - `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' + `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' ) ENGINE=InnoDB; +CREATE UNIQUE INDEX SessionID ON Presence(SessionID); +CREATE INDEX UserID ON Presence(UserID); + COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_Presence.sql b/OpenSim/Data/MySQL/Resources/002_Presence.sql deleted file mode 100644 index e65f105..0000000 --- a/OpenSim/Data/MySQL/Resources/002_Presence.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; -ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; -ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_Presence.sql b/OpenSim/Data/MySQL/Resources/003_Presence.sql deleted file mode 100644 index 0efefa8..0000000 --- a/OpenSim/Data/MySQL/Resources/003_Presence.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -CREATE UNIQUE INDEX SessionID ON Presence(SessionID); -CREATE INDEX UserID ON Presence(UserID); - -COMMIT; -- cgit v1.1