29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenSim.Framework;
37 namespace OpenSim.Data.
Null
45 Dictionary<UUID, PresenceData> m_presenceData =
new Dictionary<UUID, PresenceData>();
60 return Instance.Store(data);
65 m_presenceData[data.SessionID] = data;
72 return Instance.Get(sessionID);
74 if (m_presenceData.ContainsKey(sessionID))
76 return m_presenceData[sessionID];
86 Instance.LogoutRegionAgents(regionID);
90 List<UUID> toBeDeleted =
new List<UUID>();
91 foreach (KeyValuePair<UUID, PresenceData> kvp
in m_presenceData)
92 if (kvp.Value.RegionID == regionID)
93 toBeDeleted.Add(kvp.Key);
95 foreach (UUID u
in toBeDeleted)
96 m_presenceData.Remove(u);
101 if (Instance !=
this)
102 return Instance.ReportAgent(sessionID, regionID);
104 if (m_presenceData.ContainsKey(sessionID))
106 m_presenceData[sessionID].RegionID = regionID;
115 if (Instance !=
this)
116 return Instance.Get(field, data);
121 List<PresenceData> presences =
new List<PresenceData>();
122 if (field ==
"UserID")
133 return presences.ToArray();
135 else if (field ==
"SessionID")
137 UUID session = UUID.Zero;
138 if (!UUID.TryParse(data, out session))
139 return presences.ToArray();
141 if (m_presenceData.ContainsKey(session))
143 presences.Add(m_presenceData[session]);
144 return presences.ToArray();
147 else if (field ==
"RegionID")
149 UUID region = UUID.Zero;
150 if (!UUID.TryParse(data, out region))
151 return presences.ToArray();
155 return presences.ToArray();
161 if (p.
Data.ContainsKey(field) && p.Data[field] == data)
164 return presences.ToArray();
167 return presences.ToArray();
171 public bool Delete(
string field,
string data)
176 if (Instance !=
this)
177 return Instance.Delete(field, data);
179 List<UUID> presences =
new List<UUID>();
180 if (field ==
"UserID")
182 foreach (KeyValuePair<UUID, PresenceData> p
in m_presenceData)
183 if (p.Value.UserID == data)
184 presences.Add(p.Key);
186 else if (field ==
"SessionID")
188 UUID session = UUID.Zero;
189 if (UUID.TryParse(data, out session))
191 if (m_presenceData.ContainsKey(session))
193 presences.Add(session);
197 else if (field ==
"RegionID")
199 UUID region = UUID.Zero;
200 if (UUID.TryParse(data, out region))
202 foreach (KeyValuePair<UUID, PresenceData> p
in m_presenceData)
203 if (p.Value.RegionID == region)
204 presences.Add(p.Key);
209 foreach (KeyValuePair<UUID, PresenceData> p
in m_presenceData)
211 if (p.Value.Data.ContainsKey(field) && p.Value.Data[field] == data)
212 presences.Add(p.Key);
216 foreach (UUID u
in presences)
217 m_presenceData.Remove(u);
219 if (presences.Count == 0)
227 if (Instance !=
this)
228 return Instance.VerifyAgent(agentId, secureSessionID);
bool VerifyAgent(UUID agentId, UUID secureSessionID)
bool Store(PresenceData data)
An interface for connecting to the presence datastore
void LogoutRegionAgents(UUID regionID)
Dictionary< string, string > Data
static NullPresenceData Instance
bool ReportAgent(UUID sessionID, UUID regionID)
NullPresenceData(string connectionString, string realm)
bool Delete(string field, string data)
PresenceData Get(UUID sessionID)
PresenceData[] Get(string field, string data)