diff options
author | Justin Clark-Casey (justincc) | 2010-03-04 22:43:30 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-03-04 22:43:30 +0000 |
commit | a1643c78beddf6e96d6bf124cdee8ef8c96cab51 (patch) | |
tree | 0b364ecb7c85aa08168975bd6b76b0f680c1d015 /OpenSim/Data/Null | |
parent | move linden notecard parsing from LSL_Api.cs to SLUtil so that region modules... (diff) | |
download | opensim-SC-a1643c78beddf6e96d6bf124cdee8ef8c96cab51.zip opensim-SC-a1643c78beddf6e96d6bf124cdee8ef8c96cab51.tar.gz opensim-SC-a1643c78beddf6e96d6bf124cdee8ef8c96cab51.tar.bz2 opensim-SC-a1643c78beddf6e96d6bf124cdee8ef8c96cab51.tar.xz |
remove test presence from NullPresenceData since this appears to stop existing sessions with home locations from being picked up
only tested for a single user so this may still fail for multiple users
this may well be all academic anyway since standalone need to persistently store home location in presence data in some way
Diffstat (limited to 'OpenSim/Data/Null')
-rw-r--r-- | OpenSim/Data/Null/NullPresenceData.cs | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs index 5f78691..555c92f 100644 --- a/OpenSim/Data/Null/NullPresenceData.cs +++ b/OpenSim/Data/Null/NullPresenceData.cs | |||
@@ -28,6 +28,8 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | ||
32 | using log4net; | ||
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
33 | using OpenSim.Data; | 35 | using OpenSim.Data; |
@@ -36,6 +38,8 @@ namespace OpenSim.Data.Null | |||
36 | { | 38 | { |
37 | public class NullPresenceData : IPresenceData | 39 | public class NullPresenceData : IPresenceData |
38 | { | 40 | { |
41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
39 | private static NullPresenceData Instance; | 43 | private static NullPresenceData Instance; |
40 | 44 | ||
41 | Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>(); | 45 | Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>(); |
@@ -48,20 +52,25 @@ namespace OpenSim.Data.Null | |||
48 | 52 | ||
49 | //Console.WriteLine("[XXX] NullRegionData constructor"); | 53 | //Console.WriteLine("[XXX] NullRegionData constructor"); |
50 | // Let's stick in a test presence | 54 | // Let's stick in a test presence |
55 | /* | ||
51 | PresenceData p = new PresenceData(); | 56 | PresenceData p = new PresenceData(); |
52 | p.SessionID = UUID.Zero; | 57 | p.SessionID = UUID.Zero; |
53 | p.UserID = UUID.Zero.ToString(); | 58 | p.UserID = UUID.Zero.ToString(); |
54 | p.Data = new Dictionary<string, string>(); | 59 | p.Data = new Dictionary<string, string>(); |
55 | p.Data["Online"] = true.ToString(); | 60 | p.Data["Online"] = true.ToString(); |
56 | m_presenceData.Add(UUID.Zero, p); | 61 | m_presenceData.Add(UUID.Zero, p); |
62 | */ | ||
57 | } | 63 | } |
58 | } | 64 | } |
59 | 65 | ||
60 | public bool Store(PresenceData data) | 66 | public bool Store(PresenceData data) |
61 | { | 67 | { |
62 | if (Instance != this) | 68 | if (Instance != this) |
63 | return Instance.Store(data); | 69 | return Instance.Store(data); |
64 | 70 | ||
71 | // m_log.DebugFormat("[NULL PRESENCE DATA]: Storing presence {0}", data.UserID); | ||
72 | // Console.WriteLine("HOME for " + data.UserID + " is " + (data.Data.ContainsKey("HomeRegionID") ? data.Data["HomeRegionID"] : "Not found")); | ||
73 | |||
65 | m_presenceData[data.SessionID] = data; | 74 | m_presenceData[data.SessionID] = data; |
66 | return true; | 75 | return true; |
67 | } | 76 | } |
@@ -100,6 +109,7 @@ namespace OpenSim.Data.Null | |||
100 | { | 109 | { |
101 | if (Instance != this) | 110 | if (Instance != this) |
102 | return Instance.ReportAgent(sessionID, regionID, position, lookAt); | 111 | return Instance.ReportAgent(sessionID, regionID, position, lookAt); |
112 | |||
103 | if (m_presenceData.ContainsKey(sessionID)) | 113 | if (m_presenceData.ContainsKey(sessionID)) |
104 | { | 114 | { |
105 | m_presenceData[sessionID].RegionID = regionID; | 115 | m_presenceData[sessionID].RegionID = regionID; |
@@ -112,7 +122,7 @@ namespace OpenSim.Data.Null | |||
112 | } | 122 | } |
113 | 123 | ||
114 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | 124 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) |
115 | { | 125 | { |
116 | if (Instance != this) | 126 | if (Instance != this) |
117 | return Instance.SetHomeLocation(userID, regionID, position, lookAt); | 127 | return Instance.SetHomeLocation(userID, regionID, position, lookAt); |
118 | 128 | ||
@@ -121,27 +131,40 @@ namespace OpenSim.Data.Null | |||
121 | { | 131 | { |
122 | if (p.UserID == userID) | 132 | if (p.UserID == userID) |
123 | { | 133 | { |
134 | // m_log.DebugFormat( | ||
135 | // "[NULL PRESENCE DATA]: Setting home location {0} {1} {2} for {3}", | ||
136 | // regionID, position, lookAt, p.UserID); | ||
137 | |||
124 | p.Data["HomeRegionID"] = regionID.ToString(); | 138 | p.Data["HomeRegionID"] = regionID.ToString(); |
125 | p.Data["HomePosition"] = position.ToString(); | 139 | p.Data["HomePosition"] = position.ToString(); |
126 | p.Data["HomeLookAt"] = lookAt.ToString(); | 140 | p.Data["HomeLookAt"] = lookAt.ToString(); |
127 | foundone = true; | 141 | foundone = true; |
128 | } | 142 | } |
129 | } | 143 | } |
130 | 144 | ||
131 | return foundone; | 145 | return foundone; |
132 | } | 146 | } |
133 | 147 | ||
134 | public PresenceData[] Get(string field, string data) | 148 | public PresenceData[] Get(string field, string data) |
135 | { | 149 | { |
136 | if (Instance != this) | 150 | if (Instance != this) |
137 | return Instance.Get(field, data); | 151 | return Instance.Get(field, data); |
138 | 152 | ||
153 | // m_log.DebugFormat( | ||
154 | // "[NULL PRESENCE DATA]: Getting presence data for field {0} with parameter {1}", field, data); | ||
155 | |||
139 | List<PresenceData> presences = new List<PresenceData>(); | 156 | List<PresenceData> presences = new List<PresenceData>(); |
140 | if (field == "UserID") | 157 | if (field == "UserID") |
141 | { | 158 | { |
142 | foreach (PresenceData p in m_presenceData.Values) | 159 | foreach (PresenceData p in m_presenceData.Values) |
143 | if (p.UserID == data) | 160 | { |
144 | presences.Add(p); | 161 | if (p.UserID == data) |
162 | { | ||
163 | presences.Add(p); | ||
164 | // Console.WriteLine("HOME for " + p.UserID + " is " + (p.Data.ContainsKey("HomeRegionID") ? p.Data["HomeRegionID"] : "Not found")); | ||
165 | } | ||
166 | } | ||
167 | |||
145 | return presences.ToArray(); | 168 | return presences.ToArray(); |
146 | } | 169 | } |
147 | else if (field == "SessionID") | 170 | else if (field == "SessionID") |
@@ -180,36 +203,46 @@ namespace OpenSim.Data.Null | |||
180 | } | 203 | } |
181 | 204 | ||
182 | public void Prune(string userID) | 205 | public void Prune(string userID) |
183 | { | 206 | { |
184 | if (Instance != this) | 207 | if (Instance != this) |
185 | { | 208 | { |
186 | Instance.Prune(userID); | 209 | Instance.Prune(userID); |
187 | return; | 210 | return; |
188 | } | 211 | } |
189 | 212 | ||
213 | // m_log.DebugFormat("[NULL PRESENCE DATA]: Prune called for {0}", userID); | ||
214 | |||
190 | List<UUID> deleteSessions = new List<UUID>(); | 215 | List<UUID> deleteSessions = new List<UUID>(); |
191 | int online = 0; | 216 | int online = 0; |
192 | 217 | ||
193 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) | 218 | foreach (KeyValuePair<UUID, PresenceData> kvp in m_presenceData) |
194 | { | 219 | { |
220 | m_log.DebugFormat("Online: {0}", kvp.Value.Data["Online"]); | ||
221 | |||
195 | bool on = false; | 222 | bool on = false; |
196 | if (bool.TryParse(kvp.Value.Data["Online"], out on) && on) | 223 | if (bool.TryParse(kvp.Value.Data["Online"], out on) && on) |
197 | online++; | 224 | online++; |
198 | else | 225 | else |
199 | deleteSessions.Add(kvp.Key); | 226 | deleteSessions.Add(kvp.Key); |
200 | } | 227 | } |
228 | |||
229 | // m_log.DebugFormat("[NULL PRESENCE DATA]: online [{0}], deleteSession.Count [{1}]", online, deleteSessions.Count); | ||
230 | |||
231 | // Leave one session behind so that we can pick up details such as home location | ||
201 | if (online == 0 && deleteSessions.Count > 0) | 232 | if (online == 0 && deleteSessions.Count > 0) |
202 | deleteSessions.RemoveAt(0); | 233 | deleteSessions.RemoveAt(0); |
203 | 234 | ||
204 | foreach (UUID s in deleteSessions) | 235 | foreach (UUID s in deleteSessions) |
205 | m_presenceData.Remove(s); | 236 | m_presenceData.Remove(s); |
206 | |||
207 | } | 237 | } |
208 | 238 | ||
209 | public bool Delete(string field, string data) | 239 | public bool Delete(string field, string data) |
210 | { | 240 | { |
241 | // m_log.DebugFormat( | ||
242 | // "[NULL PRESENCE DATA]: Deleting presence data for field {0} with parameter {1}", field, data); | ||
243 | |||
211 | if (Instance != this) | 244 | if (Instance != this) |
212 | return Delete(field, data); | 245 | return Instance.Delete(field, data); |
213 | 246 | ||
214 | List<UUID> presences = new List<UUID>(); | 247 | List<UUID> presences = new List<UUID>(); |
215 | if (field == "UserID") | 248 | if (field == "UserID") |