aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-02-25 04:22:51 +0000
committerMelanie2010-02-25 04:22:51 +0000
commit44d5b2910ff7f794c960d90006149522c0844c5f (patch)
treebf5cae26f72e5b3bdd18416f30831dccc940ad4e /OpenSim
parentImplement friend perms (diff)
downloadopensim-SC-44d5b2910ff7f794c960d90006149522c0844c5f.zip
opensim-SC-44d5b2910ff7f794c960d90006149522c0844c5f.tar.gz
opensim-SC-44d5b2910ff7f794c960d90006149522c0844c5f.tar.bz2
opensim-SC-44d5b2910ff7f794c960d90006149522c0844c5f.tar.xz
Implement initial online notifications
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 0d9fd94..7c81d6a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -44,6 +44,7 @@ using OpenSim.Server.Base;
44using OpenSim.Framework.Servers.HttpServer; 44using OpenSim.Framework.Servers.HttpServer;
45using log4net; 45using log4net;
46using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 46using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
47using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
47 48
48namespace OpenSim.Region.CoreModules.Avatar.Friends 49namespace OpenSim.Region.CoreModules.Avatar.Friends
49{ 50{
@@ -250,6 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
250 private void OnNewClient(IClientAPI client) 251 private void OnNewClient(IClientAPI client)
251 { 252 {
252 client.OnLogout += OnLogout; 253 client.OnLogout += OnLogout;
254 client.OnEconomyDataRequest += SendPresence;
253 255
254 if (m_Friends.ContainsKey(client.AgentId)) 256 if (m_Friends.ContainsKey(client.AgentId))
255 { 257 {
@@ -311,5 +313,67 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
311 } 313 }
312 } 314 }
313 315
316 private void SendPresence(UUID agentID)
317 {
318 if (!m_Friends.ContainsKey(agentID))
319 return;
320
321 IClientAPI client = LocateClientObject(agentID);
322 if (client == null)
323 return;
324
325 List<string> friendList = new List<string>();
326
327 foreach (FriendInfo fi in m_Friends[agentID].Friends)
328 friendList.Add(fi.Friend);
329
330 PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray());
331
332 List<UUID> online = new List<UUID>();
333
334 foreach (PresenceInfo pi in presence)
335 {
336 if (pi.Online)
337 online.Add(new UUID(pi.UserID));
338 }
339
340 client.SendAgentOnline(online.ToArray());
341 }
342
343 //
344 // Find the client for a ID
345 //
346 private IClientAPI LocateClientObject(UUID agentID)
347 {
348 Scene scene=GetClientScene(agentID);
349 if(scene == null)
350 return null;
351
352 ScenePresence presence=scene.GetScenePresence(agentID);
353 if(presence == null)
354 return null;
355
356 return presence.ControllingClient;
357 }
358
359 //
360 // Find the scene for an agent
361 //
362 private Scene GetClientScene(UUID agentId)
363 {
364 lock (m_Scenes)
365 {
366 foreach (Scene scene in m_Scenes)
367 {
368 ScenePresence presence = scene.GetScenePresence(agentId);
369 if (presence != null)
370 {
371 if (!presence.IsChildAgent)
372 return scene;
373 }
374 }
375 }
376 return null;
377 }
314 } 378 }
315} 379}