aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/IGridUserData.cs9
-rw-r--r--OpenSim/Data/IPresenceData.cs4
-rw-r--r--OpenSim/Data/MSSQL/MSSQLGridUserData.cs8
-rw-r--r--OpenSim/Data/MSSQL/MSSQLPresenceData.cs72
-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
-rw-r--r--OpenSim/Data/Null/NullPresenceData.cs62
10 files changed, 25 insertions, 228 deletions
diff --git a/OpenSim/Data/IGridUserData.cs b/OpenSim/Data/IGridUserData.cs
index bd7a435..e15a1f8 100644
--- a/OpenSim/Data/IGridUserData.cs
+++ b/OpenSim/Data/IGridUserData.cs
@@ -37,6 +37,11 @@ namespace OpenSim.Data
37 { 37 {
38 public string UserID; 38 public string UserID;
39 public Dictionary<string, string> Data; 39 public Dictionary<string, string> Data;
40
41 public GridUserData()
42 {
43 Data = new Dictionary<string, string>();
44 }
40 } 45 }
41 46
42 /// <summary> 47 /// <summary>
@@ -44,7 +49,7 @@ namespace OpenSim.Data
44 /// </summary> 49 /// </summary>
45 public interface IGridUserData 50 public interface IGridUserData
46 { 51 {
47 GridUserData GetGridUserData(string userID); 52 GridUserData Get(string userID);
48 bool StoreGridUserData(GridUserData data); 53 bool Store(GridUserData data);
49 } 54 }
50} \ No newline at end of file 55} \ No newline at end of file
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs
index 71d0e31..b871f56 100644
--- a/OpenSim/Data/IPresenceData.cs
+++ b/OpenSim/Data/IPresenceData.cs
@@ -50,10 +50,8 @@ namespace OpenSim.Data
50 50
51 PresenceData Get(UUID sessionID); 51 PresenceData Get(UUID sessionID);
52 void LogoutRegionAgents(UUID regionID); 52 void LogoutRegionAgents(UUID regionID);
53 bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt); 53 bool ReportAgent(UUID sessionID, UUID regionID);
54 bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt);
55 PresenceData[] Get(string field, string data); 54 PresenceData[] Get(string field, string data);
56 void Prune(string userID);
57 bool Delete(string field, string val); 55 bool Delete(string field, string val);
58 } 56 }
59} 57}
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
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 public MSSQLGridUserData(string connectionString, string realm) : 48 public MSSQLGridUserData(string connectionString, string realm) :
49 base(connectionString, realm, "UserGrid") 49 base(connectionString, realm, "GridUserStore")
50 { 50 {
51 } 51 }
52 52
53 public GridUserData GetGridUserData(string userID) 53 public GridUserData Get(string userID)
54 { 54 {
55 GridUserData[] ret = Get("UserID", userID); 55 GridUserData[] ret = Get("UserID", userID);
56 56
@@ -60,9 +60,5 @@ namespace OpenSim.Data.MSSQL
60 return ret[0]; 60 return ret[0];
61 } 61 }
62 62
63 public bool StoreGridUserData(GridUserData data)
64 {
65 return Store(data);
66 }
67 } 63 }
68} 64}
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
67 using (SqlCommand cmd = new SqlCommand()) 67 using (SqlCommand cmd = new SqlCommand())
68 { 68 {
69 69
70 cmd.CommandText = String.Format("UPDATE {0} SET Online='false' WHERE [RegionID]=@RegionID", m_Realm); 70 cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm);
71 71
72 cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); 72 cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString()));
73 cmd.Connection = conn; 73 cmd.Connection = conn;
@@ -76,8 +76,7 @@ namespace OpenSim.Data.MSSQL
76 } 76 }
77 } 77 }
78 78
79 public bool ReportAgent(UUID sessionID, UUID regionID, string position, 79 public bool ReportAgent(UUID sessionID, UUID regionID)
80 string lookAt)
81 { 80 {
82 PresenceData[] pd = Get("SessionID", sessionID.ToString()); 81 PresenceData[] pd = Get("SessionID", sessionID.ToString());
83 if (pd.Length == 0) 82 if (pd.Length == 0)
@@ -88,16 +87,11 @@ namespace OpenSim.Data.MSSQL
88 { 87 {
89 88
90 cmd.CommandText = String.Format(@"UPDATE {0} SET 89 cmd.CommandText = String.Format(@"UPDATE {0} SET
91 [RegionID] = @RegionID, 90 [RegionID] = @RegionID
92 [Position] = @Position,
93 [LookAt] = @LookAt,
94 [Online] = 'true'
95 WHERE [SessionID] = @SessionID", m_Realm); 91 WHERE [SessionID] = @SessionID", m_Realm);
96 92
97 cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString())); 93 cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString()));
98 cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); 94 cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString()));
99 cmd.Parameters.Add(m_database.CreateParameter("@Position", position.ToString()));
100 cmd.Parameters.Add(m_database.CreateParameter("@LookAt", lookAt.ToString()));
101 cmd.Connection = conn; 95 cmd.Connection = conn;
102 conn.Open(); 96 conn.Open();
103 if (cmd.ExecuteNonQuery() == 0) 97 if (cmd.ExecuteNonQuery() == 0)
@@ -106,65 +100,5 @@ namespace OpenSim.Data.MSSQL
106 return true; 100 return true;
107 } 101 }
108 102
109 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
110 {
111 PresenceData[] pd = Get("UserID", userID);
112 if (pd.Length == 0)
113 return false;
114
115 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
116 using (SqlCommand cmd = new SqlCommand())
117 {
118
119 cmd.CommandText = String.Format(@"UPDATE {0} SET
120 [HomeRegionID] = @HomeRegionID,
121 [HomePosition] = @HomePosition,
122 [HomeLookAt] = @HomeLookAt
123 WHERE [UserID] = @UserID", m_Realm);
124
125 cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID));
126 cmd.Parameters.Add(m_database.CreateParameter("@HomeRegionID", regionID.ToString()));
127 cmd.Parameters.Add(m_database.CreateParameter("@HomePosition", position));
128 cmd.Parameters.Add(m_database.CreateParameter("@HomeLookAt", lookAt));
129 cmd.Connection = conn;
130 conn.Open();
131 if (cmd.ExecuteNonQuery() == 0)
132 return false;
133 }
134 return true;
135 }
136
137 public void Prune(string userID)
138 {
139 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
140 using (SqlCommand cmd = new SqlCommand())
141 {
142 cmd.CommandText = String.Format("SELECT * from {0} WHERE [UserID] = @UserID", m_Realm);
143
144 cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID));
145 cmd.Connection = conn;
146 conn.Open();
147
148 using (SqlDataReader reader = cmd.ExecuteReader())
149 {
150 List<UUID> deleteSessions = new List<UUID>();
151 int online = 0;
152
153 while (reader.Read())
154 {
155 if (bool.Parse(reader["Online"].ToString()))
156 online++;
157 else
158 deleteSessions.Add(new UUID(reader["SessionID"].ToString()));
159 }
160
161 if (online == 0 && deleteSessions.Count > 0)
162 deleteSessions.RemoveAt(0);
163
164 foreach (UUID s in deleteSessions)
165 Delete("SessionID", s.ToString());
166 }
167 }
168 }
169 } 103 }
170} 104}
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;
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs
index b98b5c9..91f1cc5 100644
--- a/OpenSim/Data/Null/NullPresenceData.cs
+++ b/OpenSim/Data/Null/NullPresenceData.cs
@@ -96,45 +96,20 @@ namespace OpenSim.Data.Null
96 m_presenceData.Remove(u); 96 m_presenceData.Remove(u);
97 } 97 }
98 98
99 public bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt) 99 public bool ReportAgent(UUID sessionID, UUID regionID)
100 { 100 {
101 if (Instance != this) 101 if (Instance != this)
102 return Instance.ReportAgent(sessionID, regionID, position, lookAt); 102 return Instance.ReportAgent(sessionID, regionID);
103 103
104 if (m_presenceData.ContainsKey(sessionID)) 104 if (m_presenceData.ContainsKey(sessionID))
105 { 105 {
106 m_presenceData[sessionID].RegionID = regionID; 106 m_presenceData[sessionID].RegionID = regionID;
107 m_presenceData[sessionID].Data["Position"] = position;
108 m_presenceData[sessionID].Data["LookAt"] = lookAt;
109 return true; 107 return true;
110 } 108 }
111 109
112 return false; 110 return false;
113 } 111 }
114 112
115 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
116 {
117 if (Instance != this)
118 return Instance.SetHomeLocation(userID, regionID, position, lookAt);
119
120 bool foundone = false;
121 foreach (PresenceData p in m_presenceData.Values)
122 {
123 if (p.UserID == userID)
124 {
125// m_log.DebugFormat(
126// "[NULL PRESENCE DATA]: Setting home location {0} {1} {2} for {3}",
127// regionID, position, lookAt, p.UserID);
128
129 p.Data["HomeRegionID"] = regionID.ToString();
130 p.Data["HomePosition"] = position.ToString();
131 p.Data["HomeLookAt"] = lookAt.ToString();
132 foundone = true;
133 }
134 }
135
136 return foundone;
137 }
138 113
139 public PresenceData[] Get(string field, string data) 114 public PresenceData[] Get(string field, string data)
140 { 115 {
@@ -193,39 +168,6 @@ namespace OpenSim.Data.Null
193 return presences.ToArray(); 168 return presences.ToArray();
194 } 169 }
195 170
196 public void Prune(string userID)
197 {
198 if (Instance != this)
199 {
200 Instance.Prune(userID);
201 return;
202 }
203
204// m_log.DebugFormat("[NULL PRESENCE DATA]: Prune called for {0}", userID);
205
206 List<UUID> deleteSessions = new List<UUID>();
207 int online = 0;
208
209 foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData)
210 {
211// m_log.DebugFormat("Online: {0}", kvp.Value.Data["Online"]);
212
213 bool on = false;
214 if (bool.TryParse(kvp.Value.Data["Online"], out on) && on)
215 online++;
216 else
217 deleteSessions.Add(kvp.Key);
218 }
219
220// m_log.DebugFormat("[NULL PRESENCE DATA]: online [{0}], deleteSession.Count [{1}]", online, deleteSessions.Count);
221
222 // Leave one session behind so that we can pick up details such as home location
223 if (online == 0 && deleteSessions.Count > 0)
224 deleteSessions.RemoveAt(0);
225
226 foreach (UUID s in deleteSessions)
227 m_presenceData.Remove(s);
228 }
229 171
230 public bool Delete(string field, string data) 172 public bool Delete(string field, string data)
231 { 173 {