aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Addons/Groups/GroupsMessagingModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Addons/Groups/GroupsMessagingModule.cs')
-rw-r--r--OpenSim/Addons/Groups/GroupsMessagingModule.cs594
1 files changed, 594 insertions, 0 deletions
diff --git a/OpenSim/Addons/Groups/GroupsMessagingModule.cs b/OpenSim/Addons/Groups/GroupsMessagingModule.cs
new file mode 100644
index 0000000..d172d48
--- /dev/null
+++ b/OpenSim/Addons/Groups/GroupsMessagingModule.cs
@@ -0,0 +1,594 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenMetaverse.StructuredData;
37using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces;
41using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
42
43namespace OpenSim.Groups
44{
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsMessagingModule")]
46 public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private List<Scene> m_sceneList = new List<Scene>();
51 private IPresenceService m_presenceService;
52
53 private IMessageTransferModule m_msgTransferModule = null;
54
55 private IGroupsServicesConnector m_groupData = null;
56
57 // Config Options
58 private bool m_groupMessagingEnabled = false;
59 private bool m_debugEnabled = true;
60
61 /// <summary>
62 /// If enabled, module only tries to send group IMs to online users by querying cached presence information.
63 /// </summary>
64 private bool m_messageOnlineAgentsOnly;
65
66 /// <summary>
67 /// Cache for online users.
68 /// </summary>
69 /// <remarks>
70 /// Group ID is key, presence information for online members is value.
71 /// Will only be non-null if m_messageOnlineAgentsOnly = true
72 /// We cache here so that group messages don't constantly have to re-request the online user list to avoid
73 /// attempted expensive sending of messages to offline users.
74 /// The tradeoff is that a user that comes online will not receive messages consistently from all other users
75 /// until caches have updated.
76 /// Therefore, we set the cache expiry to just 20 seconds.
77 /// </remarks>
78 private ExpiringCache<UUID, PresenceInfo[]> m_usersOnlineCache;
79
80 private int m_usersOnlineCacheExpirySeconds = 20;
81
82 #region Region Module interfaceBase Members
83
84 public void Initialise(IConfigSource config)
85 {
86 IConfig groupsConfig = config.Configs["Groups"];
87
88 if (groupsConfig == null)
89 // Do not run this module by default.
90 return;
91
92 // if groups aren't enabled, we're not needed.
93 // if we're not specified as the connector to use, then we're not wanted
94 if ((groupsConfig.GetBoolean("Enabled", false) == false)
95 || (groupsConfig.GetString("MessagingModule", "") != Name))
96 {
97 m_groupMessagingEnabled = false;
98 return;
99 }
100
101 m_groupMessagingEnabled = groupsConfig.GetBoolean("MessagingEnabled", true);
102
103 if (!m_groupMessagingEnabled)
104 return;
105
106 m_messageOnlineAgentsOnly = groupsConfig.GetBoolean("MessageOnlineUsersOnly", false);
107
108 if (m_messageOnlineAgentsOnly)
109 m_usersOnlineCache = new ExpiringCache<UUID, PresenceInfo[]>();
110
111 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
112
113 m_log.InfoFormat(
114 "[Groups.Messaging]: GroupsMessagingModule enabled with MessageOnlineOnly = {0}, DebugEnabled = {1}",
115 m_messageOnlineAgentsOnly, m_debugEnabled);
116 }
117
118 public void AddRegion(Scene scene)
119 {
120 if (!m_groupMessagingEnabled)
121 return;
122
123 scene.RegisterModuleInterface<IGroupsMessagingModule>(this);
124 m_sceneList.Add(scene);
125
126 scene.EventManager.OnNewClient += OnNewClient;
127 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
128 scene.EventManager.OnClientLogin += OnClientLogin;
129 }
130
131 public void RegionLoaded(Scene scene)
132 {
133 if (!m_groupMessagingEnabled)
134 return;
135
136 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
137
138 m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>();
139
140 // No groups module, no groups messaging
141 if (m_groupData == null)
142 {
143 m_log.Error("[Groups.Messaging]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled.");
144 RemoveRegion(scene);
145 return;
146 }
147
148 m_msgTransferModule = scene.RequestModuleInterface<IMessageTransferModule>();
149
150 // No message transfer module, no groups messaging
151 if (m_msgTransferModule == null)
152 {
153 m_log.Error("[Groups.Messaging]: Could not get MessageTransferModule");
154 RemoveRegion(scene);
155 return;
156 }
157
158 if (m_presenceService == null)
159 m_presenceService = scene.PresenceService;
160
161 }
162
163 public void RemoveRegion(Scene scene)
164 {
165 if (!m_groupMessagingEnabled)
166 return;
167
168 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
169
170 m_sceneList.Remove(scene);
171 scene.EventManager.OnNewClient -= OnNewClient;
172 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
173 scene.EventManager.OnClientLogin -= OnClientLogin;
174 scene.UnregisterModuleInterface<IGroupsMessagingModule>(this);
175 }
176
177 public void Close()
178 {
179 if (!m_groupMessagingEnabled)
180 return;
181
182 if (m_debugEnabled) m_log.Debug("[Groups.Messaging]: Shutting down GroupsMessagingModule module.");
183
184 m_sceneList.Clear();
185
186 m_groupData = null;
187 m_msgTransferModule = null;
188 }
189
190 public Type ReplaceableInterface
191 {
192 get { return null; }
193 }
194
195 public string Name
196 {
197 get { return "Groups Messaging Module V2"; }
198 }
199
200 public void PostInitialise()
201 {
202 // NoOp
203 }
204
205 #endregion
206
207
208 /// <summary>
209 /// Not really needed, but does confirm that the group exists.
210 /// </summary>
211 public bool StartGroupChatSession(UUID agentID, UUID groupID)
212 {
213 if (m_debugEnabled)
214 m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
215
216 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID.ToString(), groupID, null);
217
218 if (groupInfo != null)
219 {
220 return true;
221 }
222 else
223 {
224 return false;
225 }
226 }
227
228 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
229 {
230 List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(new UUID(im.fromAgentID).ToString(), groupID);
231 int groupMembersCount = groupMembers.Count;
232
233 if (m_messageOnlineAgentsOnly)
234 {
235 string[] t1 = groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString()).ToArray();
236
237 // We cache in order not to overwhlem the presence service on large grids with many groups. This does
238 // mean that members coming online will not see all group members until after m_usersOnlineCacheExpirySeconds has elapsed.
239 // (assuming this is the same across all grid simulators).
240 PresenceInfo[] onlineAgents;
241 if (!m_usersOnlineCache.TryGetValue(groupID, out onlineAgents))
242 {
243 onlineAgents = m_presenceService.GetAgents(t1);
244 m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds);
245 }
246
247 HashSet<string> onlineAgentsUuidSet = new HashSet<string>();
248 Array.ForEach<PresenceInfo>(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID));
249
250 groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList();
251
252 // if (m_debugEnabled)
253// m_log.DebugFormat(
254// "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members, {2} online",
255// groupID, groupMembersCount, groupMembers.Count());
256 }
257 else
258 {
259 if (m_debugEnabled)
260 m_log.DebugFormat(
261 "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members",
262 groupID, groupMembers.Count);
263 }
264
265 int requestStartTick = Environment.TickCount;
266
267 foreach (GroupMembersData member in groupMembers)
268 {
269 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID.ToString(), groupID))
270 {
271 // Don't deliver messages to people who have dropped this session
272 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: {0} has dropped session, not delivering to them", member.AgentID);
273 continue;
274 }
275
276 // Copy Message
277 GridInstantMessage msg = new GridInstantMessage();
278 msg.imSessionID = groupID.Guid;
279 msg.fromAgentName = im.fromAgentName;
280 msg.message = im.message;
281 msg.dialog = im.dialog;
282 msg.offline = im.offline;
283 msg.ParentEstateID = im.ParentEstateID;
284 msg.Position = im.Position;
285 msg.RegionID = im.RegionID;
286 msg.binaryBucket = im.binaryBucket;
287 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
288
289 msg.fromAgentID = im.fromAgentID;
290 msg.fromGroup = true;
291
292 msg.toAgentID = member.AgentID.Guid;
293
294 IClientAPI client = GetActiveClient(member.AgentID);
295 if (client == null)
296 {
297 // If they're not local, forward across the grid
298 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Delivering to {0} via Grid", member.AgentID);
299 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
300 }
301 else
302 {
303 // Deliver locally, directly
304 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
305 ProcessMessageFromGroupSession(msg);
306 }
307 }
308
309 // Temporary for assessing how long it still takes to send messages to large online groups.
310 if (m_messageOnlineAgentsOnly)
311 m_log.DebugFormat(
312 "[Groups.Messaging]: SendMessageToGroup for group {0} with {1} visible members, {2} online took {3}ms",
313 groupID, groupMembersCount, groupMembers.Count(), Environment.TickCount - requestStartTick);
314 }
315
316 #region SimGridEventHandlers
317
318 void OnClientLogin(IClientAPI client)
319 {
320 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: OnInstantMessage registered for {0}", client.Name);
321 }
322
323 private void OnNewClient(IClientAPI client)
324 {
325 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: OnInstantMessage registered for {0}", client.Name);
326
327 client.OnInstantMessage += OnInstantMessage;
328 }
329
330 private void OnGridInstantMessage(GridInstantMessage msg)
331 {
332 // The instant message module will only deliver messages of dialog types:
333 // MessageFromAgent, StartTyping, StopTyping, MessageFromObject
334 //
335 // Any other message type will not be delivered to a client by the
336 // Instant Message Module
337
338
339 if (m_debugEnabled)
340 {
341 m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
342
343 DebugGridInstantMessage(msg);
344 }
345
346 // Incoming message from a group
347 if ((msg.fromGroup == true) &&
348 ((msg.dialog == (byte)InstantMessageDialog.SessionSend)
349 || (msg.dialog == (byte)InstantMessageDialog.SessionAdd)
350 || (msg.dialog == (byte)InstantMessageDialog.SessionDrop)))
351 {
352 ProcessMessageFromGroupSession(msg);
353 }
354 }
355
356 private void ProcessMessageFromGroupSession(GridInstantMessage msg)
357 {
358 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
359
360 UUID AgentID = new UUID(msg.fromAgentID);
361 UUID GroupID = new UUID(msg.imSessionID);
362
363 switch (msg.dialog)
364 {
365 case (byte)InstantMessageDialog.SessionAdd:
366 m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
367 break;
368
369 case (byte)InstantMessageDialog.SessionDrop:
370 m_groupData.AgentDroppedFromGroupChatSession(AgentID.ToString(), GroupID);
371 break;
372
373 case (byte)InstantMessageDialog.SessionSend:
374 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID.ToString(), GroupID)
375 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID.ToString(), GroupID)
376 )
377 {
378 // Agent not in session and hasn't dropped from session
379 // Add them to the session for now, and Invite them
380 m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
381
382 UUID toAgentID = new UUID(msg.toAgentID);
383 IClientAPI activeClient = GetActiveClient(toAgentID);
384 if (activeClient != null)
385 {
386 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), GroupID, null);
387 if (groupInfo != null)
388 {
389 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Sending chatterbox invite instant message");
390
391 // Force? open the group session dialog???
392 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
393 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
394 eq.ChatterboxInvitation(
395 GroupID
396 , groupInfo.GroupName
397 , new UUID(msg.fromAgentID)
398 , msg.message
399 , new UUID(msg.toAgentID)
400 , msg.fromAgentName
401 , msg.dialog
402 , msg.timestamp
403 , msg.offline == 1
404 , (int)msg.ParentEstateID
405 , msg.Position
406 , 1
407 , new UUID(msg.imSessionID)
408 , msg.fromGroup
409 , OpenMetaverse.Utils.StringToBytes(groupInfo.GroupName)
410 );
411
412 eq.ChatterBoxSessionAgentListUpdates(
413 new UUID(GroupID)
414 , new UUID(msg.fromAgentID)
415 , new UUID(msg.toAgentID)
416 , false //canVoiceChat
417 , false //isModerator
418 , false //text mute
419 );
420 }
421 }
422 }
423 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID.ToString(), GroupID))
424 {
425 // User hasn't dropped, so they're in the session,
426 // maybe we should deliver it.
427 IClientAPI client = GetActiveClient(new UUID(msg.toAgentID));
428 if (client != null)
429 {
430 // Deliver locally, directly
431 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: Delivering to {0} locally", client.Name);
432 client.SendInstantMessage(msg);
433 }
434 else
435 {
436 m_log.WarnFormat("[Groups.Messaging]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
437 }
438 }
439 break;
440
441 default:
442 m_log.WarnFormat("[Groups.Messaging]: I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString());
443 break;
444 }
445 }
446
447 #endregion
448
449
450 #region ClientEvents
451 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
452 {
453 if (m_debugEnabled)
454 {
455 m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
456
457 DebugGridInstantMessage(im);
458 }
459
460 // Start group IM session
461 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
462 {
463 if (m_debugEnabled) m_log.InfoFormat("[Groups.Messaging]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
464
465 UUID GroupID = new UUID(im.imSessionID);
466 UUID AgentID = new UUID(im.fromAgentID);
467
468 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero.ToString(), GroupID, null);
469
470 if (groupInfo != null)
471 {
472 m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
473
474 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
475
476 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
477 queue.ChatterBoxSessionAgentListUpdates(
478 GroupID
479 , AgentID
480 , new UUID(im.toAgentID)
481 , false //canVoiceChat
482 , false //isModerator
483 , false //text mute
484 );
485 }
486 }
487
488 // Send a message from locally connected client to a group
489 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
490 {
491 UUID GroupID = new UUID(im.imSessionID);
492 UUID AgentID = new UUID(im.fromAgentID);
493
494 if (m_debugEnabled)
495 m_log.DebugFormat("[Groups.Messaging]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
496
497 //If this agent is sending a message, then they want to be in the session
498 m_groupData.AgentInvitedToGroupChatSession(AgentID.ToString(), GroupID);
499
500 SendMessageToGroup(im, GroupID);
501 }
502 }
503
504 #endregion
505
506 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID)
507 {
508 if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
509
510 OSDMap moderatedMap = new OSDMap(4);
511 moderatedMap.Add("voice", OSD.FromBoolean(false));
512
513 OSDMap sessionMap = new OSDMap(4);
514 sessionMap.Add("moderated_mode", moderatedMap);
515 sessionMap.Add("session_name", OSD.FromString(groupName));
516 sessionMap.Add("type", OSD.FromInteger(0));
517 sessionMap.Add("voice_enabled", OSD.FromBoolean(false));
518
519 OSDMap bodyMap = new OSDMap(4);
520 bodyMap.Add("session_id", OSD.FromUUID(groupID));
521 bodyMap.Add("temp_session_id", OSD.FromUUID(groupID));
522 bodyMap.Add("success", OSD.FromBoolean(true));
523 bodyMap.Add("session_info", sessionMap);
524
525 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
526
527 if (queue != null)
528 {
529 queue.Enqueue(queue.BuildEvent("ChatterBoxSessionStartReply", bodyMap), remoteClient.AgentId);
530 }
531 }
532
533 private void DebugGridInstantMessage(GridInstantMessage im)
534 {
535 // Don't log any normal IMs (privacy!)
536 if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent)
537 {
538 m_log.WarnFormat("[Groups.Messaging]: IM: fromGroup({0})", im.fromGroup ? "True" : "False");
539 m_log.WarnFormat("[Groups.Messaging]: IM: Dialog({0})", ((InstantMessageDialog)im.dialog).ToString());
540 m_log.WarnFormat("[Groups.Messaging]: IM: fromAgentID({0})", im.fromAgentID.ToString());
541 m_log.WarnFormat("[Groups.Messaging]: IM: fromAgentName({0})", im.fromAgentName.ToString());
542 m_log.WarnFormat("[Groups.Messaging]: IM: imSessionID({0})", im.imSessionID.ToString());
543 m_log.WarnFormat("[Groups.Messaging]: IM: message({0})", im.message.ToString());
544 m_log.WarnFormat("[Groups.Messaging]: IM: offline({0})", im.offline.ToString());
545 m_log.WarnFormat("[Groups.Messaging]: IM: toAgentID({0})", im.toAgentID.ToString());
546 m_log.WarnFormat("[Groups.Messaging]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket"));
547 }
548 }
549
550 #region Client Tools
551
552 /// <summary>
553 /// Try to find an active IClientAPI reference for agentID giving preference to root connections
554 /// </summary>
555 private IClientAPI GetActiveClient(UUID agentID)
556 {
557 if (m_debugEnabled) m_log.WarnFormat("[Groups.Messaging]: Looking for local client {0}", agentID);
558
559 IClientAPI child = null;
560
561 // Try root avatar first
562 foreach (Scene scene in m_sceneList)
563 {
564 ScenePresence sp = scene.GetScenePresence(agentID);
565 if (sp != null)
566 {
567 if (!sp.IsChildAgent)
568 {
569 if (m_debugEnabled) m_log.WarnFormat("[Groups.Messaging]: Found root agent for client : {0}", sp.ControllingClient.Name);
570 return sp.ControllingClient;
571 }
572 else
573 {
574 if (m_debugEnabled) m_log.WarnFormat("[Groups.Messaging]: Found child agent for client : {0}", sp.ControllingClient.Name);
575 child = sp.ControllingClient;
576 }
577 }
578 }
579
580 // If we didn't find a root, then just return whichever child we found, or null if none
581 if (child == null)
582 {
583 if (m_debugEnabled) m_log.WarnFormat("[Groups.Messaging]: Could not find local client for agent : {0}", agentID);
584 }
585 else
586 {
587 if (m_debugEnabled) m_log.WarnFormat("[Groups.Messaging]: Returning child agent for client : {0}", child.Name);
588 }
589 return child;
590 }
591
592 #endregion
593 }
594}