diff options
author | Diva Canto | 2010-05-07 21:29:56 -0700 |
---|---|---|
committer | Diva Canto | 2010-05-07 21:29:56 -0700 |
commit | a58859a0d4206c194c9c56212218e2cafc2cc373 (patch) | |
tree | fed51a4e40c344b76f6b8b4d5c5b2ec0d2e142e4 /OpenSim/Data/MSSQL | |
parent | improve handling of undersize sculpt textures (diff) | |
download | opensim-SC_OLD-a58859a0d4206c194c9c56212218e2cafc2cc373.zip opensim-SC_OLD-a58859a0d4206c194c9c56212218e2cafc2cc373.tar.gz opensim-SC_OLD-a58859a0d4206c194c9c56212218e2cafc2cc373.tar.bz2 opensim-SC_OLD-a58859a0d4206c194c9c56212218e2cafc2cc373.tar.xz |
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.
Diffstat (limited to 'OpenSim/Data/MSSQL')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGridUserData.cs | 8 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLPresenceData.cs | 72 |
2 files changed, 5 insertions, 75 deletions
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 | } |