aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLGridUserData.cs9
-rw-r--r--OpenSim/Data/MySQL/MySQLPresenceData.cs66
-rw-r--r--OpenSim/Data/MySQL/Resources/001_Presence.sql10
-rw-r--r--OpenSim/Data/MySQL/Resources/002_Presence.sql7
-rw-r--r--OpenSim/Data/MySQL/Resources/003_Presence.sql6
5 files changed, 10 insertions, 88 deletions
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
44 { 44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "UserGrid") {} 47 public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {}
48 48
49 public GridUserData GetGridUserData(string userID) 49 public GridUserData Get(string userID)
50 { 50 {
51 GridUserData[] ret = Get("UserID", userID); 51 GridUserData[] ret = Get("UserID", userID);
52 52
@@ -56,9 +56,6 @@ namespace OpenSim.Data.MySQL
56 return ret[0]; 56 return ret[0];
57 } 57 }
58 58
59 public bool StoreGridUserData(GridUserData data) 59
60 {
61 return Store(data);
62 }
63 } 60 }
64} \ No newline at end of file 61} \ 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
65 { 65 {
66 MySqlCommand cmd = new MySqlCommand(); 66 MySqlCommand cmd = new MySqlCommand();
67 67
68 cmd.CommandText = String.Format("update {0} set Online='false' where `RegionID`=?RegionID", m_Realm); 68 cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm);
69 69
70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 70 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
71 71
72 ExecuteNonQuery(cmd); 72 ExecuteNonQuery(cmd);
73 } 73 }
74 74
75 public bool ReportAgent(UUID sessionID, UUID regionID, string position, 75 public bool ReportAgent(UUID sessionID, UUID regionID)
76 string lookAt)
77 { 76 {
78 PresenceData[] pd = Get("SessionID", sessionID.ToString()); 77 PresenceData[] pd = Get("SessionID", sessionID.ToString());
79 if (pd.Length == 0) 78 if (pd.Length == 0)
@@ -81,12 +80,10 @@ namespace OpenSim.Data.MySQL
81 80
82 MySqlCommand cmd = new MySqlCommand(); 81 MySqlCommand cmd = new MySqlCommand();
83 82
84 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm); 83 cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm);
85 84
86 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); 85 cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString());
87 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); 86 cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
88 cmd.Parameters.AddWithValue("?Position", position.ToString());
89 cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString());
90 87
91 if (ExecuteNonQuery(cmd) == 0) 88 if (ExecuteNonQuery(cmd) == 0)
92 return false; 89 return false;
@@ -94,62 +91,5 @@ namespace OpenSim.Data.MySQL
94 return true; 91 return true;
95 } 92 }
96 93
97 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
98 {
99 PresenceData[] pd = Get("UserID", userID);
100 if (pd.Length == 0)
101 return false;
102
103 MySqlCommand cmd = new MySqlCommand();
104
105 cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm);
106
107 cmd.Parameters.AddWithValue("?UserID", userID);
108 cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString());
109 cmd.Parameters.AddWithValue("?HomePosition", position);
110 cmd.Parameters.AddWithValue("?HomeLookAt", lookAt);
111
112 if (ExecuteNonQuery(cmd) == 0)
113 return false;
114
115 return true;
116 }
117
118 public void Prune(string userID)
119 {
120 MySqlCommand cmd = new MySqlCommand();
121
122 cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm);
123
124 cmd.Parameters.AddWithValue("?UserID", userID);
125
126 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
127 {
128 dbcon.Open();
129
130 cmd.Connection = dbcon;
131
132 using (IDataReader reader = cmd.ExecuteReader())
133 {
134 List<UUID> deleteSessions = new List<UUID>();
135 int online = 0;
136
137 while (reader.Read())
138 {
139 if (bool.Parse(reader["Online"].ToString()))
140 online++;
141 else
142 deleteSessions.Add(new UUID(reader["SessionID"].ToString()));
143 }
144
145 // Leave one session behind so that we can pick up details such as home location
146 if (online == 0 && deleteSessions.Count > 0)
147 deleteSessions.RemoveAt(0);
148
149 foreach (UUID s in deleteSessions)
150 Delete("SessionID", s.ToString());
151 }
152 }
153 }
154 } 94 }
155} 95}
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` (
4 `UserID` VARCHAR(255) NOT NULL, 4 `UserID` VARCHAR(255) NOT NULL,
5 `RegionID` CHAR(36) NOT NULL, 5 `RegionID` CHAR(36) NOT NULL,
6 `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', 6 `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
7 `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', 7 `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'
8 `Online` CHAR(5) NOT NULL DEFAULT 'false',
9 `Login` CHAR(16) NOT NULL DEFAULT '0',
10 `Logout` CHAR(16) NOT NULL DEFAULT '0',
11 `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>',
12 `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'
13) ENGINE=InnoDB; 8) ENGINE=InnoDB;
14 9
10CREATE UNIQUE INDEX SessionID ON Presence(SessionID);
11CREATE INDEX UserID ON Presence(UserID);
12
15COMMIT; 13COMMIT;
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 @@
1BEGIN;
2
3ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL;
4ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>';
5ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>';
6
7COMMIT;
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 @@
1BEGIN;
2
3CREATE UNIQUE INDEX SessionID ON Presence(SessionID);
4CREATE INDEX UserID ON Presence(UserID);
5
6COMMIT;