aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-02 16:16:07 +0000
committerTeravus Ovares2008-06-02 16:16:07 +0000
commit3991908db5b50e764112d30e5750447db67795b5 (patch)
treebc5c47d6c26b87dd04c550ed24d5597e686e7663 /OpenSim/Region/Environment/Modules
parentFixed half completed comment in OpenSim.ini.example. (diff)
downloadopensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.zip
opensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.tar.gz
opensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.tar.bz2
opensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.tar.xz
* This update enables grid wide presence updates.
* You'll need to start-up the MessageingServer and set it up. It sets up like any of the other grid servers. * All user presence data is kept in memory for speed, while the agent is online. That means if you shutdown the messaging server or the messaging server crashes, it forgets who's online/offline. * Occasionally the region-cache will get stale if regions move around a lot. if it gets stale, run clear-cache on the messaging server console to clear the region cache.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs132
1 files changed, 122 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index c82f88d..92c808b 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27using System; 27using System;
28using System.Collections;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using libsecondlife; 31using libsecondlife;
@@ -45,6 +46,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
45 private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>(); 46 private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
46 private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); 47 private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
47 private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); 48 private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
49 private Dictionary<LLUUID, List<StoredFriendListUpdate>> StoredFriendListUpdates = new Dictionary<LLUUID, List<StoredFriendListUpdate>>();
50
48 private List<Scene> m_scene = new List<Scene>(); 51 private List<Scene> m_scene = new List<Scene>();
49 52
50 #region IRegionModule Members 53 #region IRegionModule Members
@@ -91,6 +94,73 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
91 public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req) 94 public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req)
92 { 95 {
93 m_log.Info("[FRIENDS]: Got Notification about a user! OMG"); 96 m_log.Info("[FRIENDS]: Got Notification about a user! OMG");
97 Hashtable requestData = (Hashtable)req.Params[0];
98 if (requestData.ContainsKey("agent_id") && requestData.ContainsKey("notify_id") && requestData.ContainsKey("status"))
99 {
100 LLUUID notifyAgentId = LLUUID.Zero;
101 LLUUID notifyAboutAgentId = LLUUID.Zero;
102 bool notifyOnlineStatus = false;
103
104 if ((string)requestData["status"] == "TRUE")
105 notifyOnlineStatus = true;
106
107 Helpers.TryParse((string)requestData["notify_id"], out notifyAgentId);
108
109 Helpers.TryParse((string)requestData["agent_id"], out notifyAboutAgentId);
110
111 ScenePresence avatar = GetPresenceFromAgentID(notifyAgentId);
112 if (avatar != null)
113 {
114 if (avatar.IsChildAgent)
115 {
116 StoredFriendListUpdate sob = new StoredFriendListUpdate();
117 sob.OnlineYN = notifyOnlineStatus;
118 sob.storedAbout = notifyAboutAgentId;
119 sob.storedFor = notifyAgentId;
120 lock (StoredFriendListUpdates)
121 {
122 if (StoredFriendListUpdates.ContainsKey(notifyAgentId))
123 {
124 StoredFriendListUpdates[notifyAgentId].Add(sob);
125 }
126 else
127 {
128 List<StoredFriendListUpdate> newitem = new List<StoredFriendListUpdate>();
129 newitem.Add(sob);
130 StoredFriendListUpdates.Add(notifyAgentId, newitem);
131 }
132 }
133 }
134 else
135 {
136 if (notifyOnlineStatus)
137 doFriendListUpdateOnline(notifyAboutAgentId);
138 else
139 ClientLoggedOut(notifyAboutAgentId);
140 }
141 }
142 else
143 {
144 StoredFriendListUpdate sob = new StoredFriendListUpdate();
145 sob.OnlineYN = notifyOnlineStatus;
146 sob.storedAbout = notifyAboutAgentId;
147 sob.storedFor = notifyAgentId;
148 lock (StoredFriendListUpdates)
149 {
150 if (StoredFriendListUpdates.ContainsKey(notifyAgentId))
151 {
152 StoredFriendListUpdates[notifyAgentId].Add(sob);
153 }
154 else
155 {
156 List<StoredFriendListUpdate> newitem = new List<StoredFriendListUpdate>();
157 newitem.Add(sob);
158 StoredFriendListUpdates.Add(notifyAgentId, newitem);
159 }
160 }
161 }
162
163 }
94 return new XmlRpcResponse(); 164 return new XmlRpcResponse();
95 } 165 }
96 166
@@ -110,24 +180,30 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
110 client.OnDenyFriendRequest += OnDenyFriendRequest; 180 client.OnDenyFriendRequest += OnDenyFriendRequest;
111 client.OnTerminateFriendship += OnTerminateFriendship; 181 client.OnTerminateFriendship += OnTerminateFriendship;
112 182
183 doFriendListUpdateOnline(client.AgentId);
184
185 }
186
187 private void doFriendListUpdateOnline(LLUUID AgentId)
188 {
113 List<FriendListItem> fl = new List<FriendListItem>(); 189 List<FriendListItem> fl = new List<FriendListItem>();
114 190
115 //bool addFLback = false; 191 //bool addFLback = false;
116 192
117 lock (FriendLists) 193 lock (FriendLists)
118 { 194 {
119 if (FriendLists.ContainsKey(client.AgentId)) 195 if (FriendLists.ContainsKey(AgentId))
120 { 196 {
121 fl = FriendLists[client.AgentId]; 197 fl = FriendLists[AgentId];
122 } 198 }
123 else 199 else
124 { 200 {
125 fl = m_scene[0].GetFriendList(client.AgentId); 201 fl = m_scene[0].GetFriendList(AgentId);
126 202
127 //lock (FriendLists) 203 //lock (FriendLists)
128 //{ 204 //{
129 if (!FriendLists.ContainsKey(client.AgentId)) 205 if (!FriendLists.ContainsKey(AgentId))
130 FriendLists.Add(client.AgentId, fl); 206 FriendLists.Add(AgentId, fl);
131 //} 207 //}
132 } 208 }
133 } 209 }
@@ -161,11 +237,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
161 { 237 {
162 foreach (FriendListItem fli in usrfl) 238 foreach (FriendListItem fli in usrfl)
163 { 239 {
164 if (fli.Friend == client.AgentId) 240 if (fli.Friend == AgentId)
165 { 241 {
166 fli.onlinestatus = true; 242 fli.onlinestatus = true;
167 LLUUID[] Agents = new LLUUID[1]; 243 LLUUID[] Agents = new LLUUID[1];
168 Agents[0] = client.AgentId; 244 Agents[0] = AgentId;
169 av.ControllingClient.SendAgentOnline(Agents); 245 av.ControllingClient.SendAgentOnline(Agents);
170 246
171 } 247 }
@@ -176,8 +252,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
176 252
177 if (UpdateUsers.Count > 0) 253 if (UpdateUsers.Count > 0)
178 { 254 {
179 255 ScenePresence avatar = GetPresenceFromAgentID(AgentId);
180 client.SendAgentOnline(UpdateUsers.ToArray()); 256 if (avatar != null)
257 {
258 avatar.ControllingClient.SendAgentOnline(UpdateUsers.ToArray());
259 }
181 260
182 } 261 }
183 } 262 }
@@ -302,6 +381,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
302 { 381 {
303 m_rootAgents.Add(avatar.UUID, avatar.RegionHandle); 382 m_rootAgents.Add(avatar.UUID, avatar.RegionHandle);
304 m_log.Info("[FRIEND]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + "."); 383 m_log.Info("[FRIEND]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
384
385 List<StoredFriendListUpdate> updateme = new List<StoredFriendListUpdate>();
386 lock (StoredFriendListUpdates)
387 {
388 if (StoredFriendListUpdates.ContainsKey(avatar.UUID))
389 {
390 updateme = StoredFriendListUpdates[avatar.UUID];
391 StoredFriendListUpdates.Remove(avatar.UUID);
392 }
393 }
394
395 if (updateme.Count > 0)
396 {
397 foreach (StoredFriendListUpdate u in updateme)
398 {
399 if (u.OnlineYN)
400 doFriendListUpdateOnline(u.storedAbout);
401 else
402 ClientLoggedOut(u.storedAbout);
403 }
404 }
305 } 405 }
306 } 406 }
307 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 407 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
@@ -441,8 +541,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
441 541
442 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 542 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
443 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1); 543 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1);
444 m_pendingFriendRequests.Remove(transactionID); 544
545
546 //LLUUID[] Agents = new LLUUID[1];
547 //Agents[0] = msg.toAgentID;
548 //av.ControllingClient.SendAgentOnline(Agents);
445 549
550 m_pendingFriendRequests.Remove(transactionID);
446 // TODO: Inform agent that the friend is online 551 // TODO: Inform agent that the friend is online
447 } 552 }
448 } 553 }
@@ -498,4 +603,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
498 603
499 #endregion 604 #endregion
500 } 605 }
606
607 public struct StoredFriendListUpdate
608 {
609 public LLUUID storedFor;
610 public LLUUID storedAbout;
611 public bool OnlineYN;
612 }
501} 613}