diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 146 |
1 files changed, 107 insertions, 39 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index fd804cd..e1b6abb 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -55,8 +55,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
55 | private IGroupsServicesConnector m_groupData = null; | 55 | private IGroupsServicesConnector m_groupData = null; |
56 | 56 | ||
57 | // Config Options | 57 | // Config Options |
58 | private bool m_groupMessagingEnabled = false; | 58 | private bool m_groupMessagingEnabled; |
59 | private bool m_debugEnabled = true; | 59 | private bool m_debugEnabled; |
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// If enabled, module only tries to send group IMs to online users by querying cached presence information. | 62 | /// If enabled, module only tries to send group IMs to online users by querying cached presence information. |
@@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
113 | if (m_messageOnlineAgentsOnly) | 113 | if (m_messageOnlineAgentsOnly) |
114 | m_usersOnlineCache = new ExpiringCache<UUID, PresenceInfo[]>(); | 114 | m_usersOnlineCache = new ExpiringCache<UUID, PresenceInfo[]>(); |
115 | 115 | ||
116 | m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); | 116 | m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled); |
117 | } | 117 | } |
118 | 118 | ||
119 | m_log.InfoFormat( | 119 | m_log.InfoFormat( |
@@ -127,6 +127,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
127 | return; | 127 | return; |
128 | 128 | ||
129 | scene.RegisterModuleInterface<IGroupsMessagingModule>(this); | 129 | scene.RegisterModuleInterface<IGroupsMessagingModule>(this); |
130 | |||
131 | scene.AddCommand( | ||
132 | "Debug", | ||
133 | this, | ||
134 | "debug groups messaging verbose", | ||
135 | "debug groups messaging verbose <true|false>", | ||
136 | "This setting turns on very verbose groups messaging debugging", | ||
137 | HandleDebugGroupsMessagingVerbose); | ||
130 | } | 138 | } |
131 | 139 | ||
132 | public void RegionLoaded(Scene scene) | 140 | public void RegionLoaded(Scene scene) |
@@ -218,6 +226,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
218 | 226 | ||
219 | #endregion | 227 | #endregion |
220 | 228 | ||
229 | private void HandleDebugGroupsMessagingVerbose(object modules, string[] args) | ||
230 | { | ||
231 | if (args.Length < 5) | ||
232 | { | ||
233 | MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>"); | ||
234 | return; | ||
235 | } | ||
236 | |||
237 | bool verbose = false; | ||
238 | if (!bool.TryParse(args[4], out verbose)) | ||
239 | { | ||
240 | MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>"); | ||
241 | return; | ||
242 | } | ||
243 | |||
244 | m_debugEnabled = verbose; | ||
245 | |||
246 | MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled); | ||
247 | } | ||
248 | |||
221 | /// <summary> | 249 | /// <summary> |
222 | /// Not really needed, but does confirm that the group exists. | 250 | /// Not really needed, but does confirm that the group exists. |
223 | /// </summary> | 251 | /// </summary> |
@@ -246,8 +274,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
246 | public void SendMessageToGroup( | 274 | public void SendMessageToGroup( |
247 | GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition) | 275 | GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition) |
248 | { | 276 | { |
277 | int requestStartTick = Environment.TickCount; | ||
278 | |||
249 | List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(sendingAgentForGroupCalls, groupID); | 279 | List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(sendingAgentForGroupCalls, groupID); |
250 | int groupMembersCount = groupMembers.Count; | 280 | int groupMembersCount = groupMembers.Count; |
281 | HashSet<string> attemptDeliveryUuidSet = null; | ||
251 | 282 | ||
252 | if (m_messageOnlineAgentsOnly) | 283 | if (m_messageOnlineAgentsOnly) |
253 | { | 284 | { |
@@ -263,10 +294,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
263 | m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds); | 294 | m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds); |
264 | } | 295 | } |
265 | 296 | ||
266 | HashSet<string> onlineAgentsUuidSet = new HashSet<string>(); | 297 | attemptDeliveryUuidSet |
267 | Array.ForEach<PresenceInfo>(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID)); | 298 | = new HashSet<string>(Array.ConvertAll<PresenceInfo, string>(onlineAgents, pi => pi.UserID)); |
268 | 299 | ||
269 | groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList(); | 300 | //Array.ForEach<PresenceInfo>(onlineAgents, pi => attemptDeliveryUuidSet.Add(pi.UserID)); |
301 | |||
302 | //groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList(); | ||
270 | 303 | ||
271 | // if (m_debugEnabled) | 304 | // if (m_debugEnabled) |
272 | // m_log.DebugFormat( | 305 | // m_log.DebugFormat( |
@@ -275,13 +308,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
275 | } | 308 | } |
276 | else | 309 | else |
277 | { | 310 | { |
311 | attemptDeliveryUuidSet | ||
312 | = new HashSet<string>(groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString())); | ||
313 | |||
278 | if (m_debugEnabled) | 314 | if (m_debugEnabled) |
279 | m_log.DebugFormat( | 315 | m_log.DebugFormat( |
280 | "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", | 316 | "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", |
281 | groupID, groupMembers.Count); | 317 | groupID, groupMembers.Count); |
282 | } | 318 | } |
283 | |||
284 | int requestStartTick = Environment.TickCount; | ||
285 | 319 | ||
286 | foreach (GroupMembersData member in groupMembers) | 320 | foreach (GroupMembersData member in groupMembers) |
287 | { | 321 | { |
@@ -309,7 +343,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
309 | 343 | ||
310 | // Copy Message | 344 | // Copy Message |
311 | GridInstantMessage msg = new GridInstantMessage(); | 345 | GridInstantMessage msg = new GridInstantMessage(); |
312 | msg.imSessionID = groupID.Guid; | 346 | msg.imSessionID = im.imSessionID; |
313 | msg.fromAgentName = im.fromAgentName; | 347 | msg.fromAgentName = im.fromAgentName; |
314 | msg.message = im.message; | 348 | msg.message = im.message; |
315 | msg.dialog = im.dialog; | 349 | msg.dialog = im.dialog; |
@@ -325,26 +359,51 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
325 | 359 | ||
326 | msg.toAgentID = member.AgentID.Guid; | 360 | msg.toAgentID = member.AgentID.Guid; |
327 | 361 | ||
328 | IClientAPI client = GetActiveClient(member.AgentID); | 362 | if (attemptDeliveryUuidSet.Contains(member.AgentID.ToString())) |
329 | if (client == null) | ||
330 | { | 363 | { |
331 | // If they're not local, forward across the grid | 364 | IClientAPI client = GetActiveClient(member.AgentID); |
332 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); | 365 | if (client == null) |
333 | m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); | 366 | { |
367 | int startTick = Environment.TickCount; | ||
368 | |||
369 | // If they're not local, forward across the grid | ||
370 | m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); | ||
371 | |||
372 | if (m_debugEnabled) | ||
373 | m_log.DebugFormat( | ||
374 | "[GROUPS-MESSAGING]: Delivering to {0} via grid took {1} ms", | ||
375 | member.AgentID, Environment.TickCount - startTick); | ||
376 | } | ||
377 | else | ||
378 | { | ||
379 | int startTick = Environment.TickCount; | ||
380 | |||
381 | ProcessMessageFromGroupSession(msg, client); | ||
382 | |||
383 | // Deliver locally, directly | ||
384 | if (m_debugEnabled) | ||
385 | m_log.DebugFormat( | ||
386 | "[GROUPS-MESSAGING]: Delivering to {0} locally took {1} ms", | ||
387 | member.AgentID, Environment.TickCount - startTick); | ||
388 | } | ||
334 | } | 389 | } |
335 | else | 390 | else |
336 | { | 391 | { |
337 | // Deliver locally, directly | 392 | int startTick = Environment.TickCount; |
338 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); | 393 | |
339 | ProcessMessageFromGroupSession(msg, client); | 394 | m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { }); |
395 | |||
396 | if (m_debugEnabled) | ||
397 | m_log.DebugFormat( | ||
398 | "[GROUPS-MESSAGING]: Handling undeliverable message for {0} took {1} ms", | ||
399 | member.AgentID, Environment.TickCount - startTick); | ||
340 | } | 400 | } |
341 | } | 401 | } |
342 | 402 | ||
343 | // Temporary for assessing how long it still takes to send messages to large online groups. | 403 | if (m_debugEnabled) |
344 | if (m_messageOnlineAgentsOnly) | ||
345 | m_log.DebugFormat( | 404 | m_log.DebugFormat( |
346 | "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} visible members, {2} online took {3}ms", | 405 | "[GROUPS-MESSAGING]: Total SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3} ms", |
347 | groupID, groupMembersCount, groupMembers.Count(), Environment.TickCount - requestStartTick); | 406 | groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick); |
348 | } | 407 | } |
349 | 408 | ||
350 | #region SimGridEventHandlers | 409 | #region SimGridEventHandlers |
@@ -407,7 +466,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
407 | 466 | ||
408 | private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) | 467 | private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) |
409 | { | 468 | { |
410 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); | 469 | if (m_debugEnabled) |
470 | m_log.DebugFormat( | ||
471 | "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}", | ||
472 | msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog); | ||
411 | 473 | ||
412 | UUID AgentID = new UUID(msg.fromAgentID); | 474 | UUID AgentID = new UUID(msg.fromAgentID); |
413 | UUID GroupID = new UUID(msg.imSessionID); | 475 | UUID GroupID = new UUID(msg.imSessionID); |
@@ -431,8 +493,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
431 | // Add them to the session for now, and Invite them | 493 | // Add them to the session for now, and Invite them |
432 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); | 494 | m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); |
433 | 495 | ||
434 | UUID toAgentID = new UUID(msg.toAgentID); | ||
435 | |||
436 | GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); | 496 | GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); |
437 | if (groupInfo != null) | 497 | if (groupInfo != null) |
438 | { | 498 | { |
@@ -577,15 +637,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
577 | // Don't log any normal IMs (privacy!) | 637 | // Don't log any normal IMs (privacy!) |
578 | if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) | 638 | if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) |
579 | { | 639 | { |
580 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); | 640 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromGroup({0})", im.fromGroup ? "True" : "False"); |
581 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); | 641 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); |
582 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); | 642 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); |
583 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); | 643 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); |
584 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); | 644 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); |
585 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); | 645 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); |
586 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); | 646 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); |
587 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); | 647 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); |
588 | m_log.WarnFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); | 648 | m_log.DebugFormat("[GROUPS-MESSAGING]: IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); |
589 | } | 649 | } |
590 | } | 650 | } |
591 | 651 | ||
@@ -596,7 +656,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
596 | /// </summary> | 656 | /// </summary> |
597 | private IClientAPI GetActiveClient(UUID agentID) | 657 | private IClientAPI GetActiveClient(UUID agentID) |
598 | { | 658 | { |
599 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); | 659 | if (m_debugEnabled) |
660 | m_log.DebugFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); | ||
600 | 661 | ||
601 | IClientAPI child = null; | 662 | IClientAPI child = null; |
602 | 663 | ||
@@ -608,12 +669,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
608 | { | 669 | { |
609 | if (!sp.IsChildAgent) | 670 | if (!sp.IsChildAgent) |
610 | { | 671 | { |
611 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); | 672 | if (m_debugEnabled) |
673 | m_log.DebugFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); | ||
674 | |||
612 | return sp.ControllingClient; | 675 | return sp.ControllingClient; |
613 | } | 676 | } |
614 | else | 677 | else |
615 | { | 678 | { |
616 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); | 679 | if (m_debugEnabled) |
680 | m_log.DebugFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); | ||
681 | |||
617 | child = sp.ControllingClient; | 682 | child = sp.ControllingClient; |
618 | } | 683 | } |
619 | } | 684 | } |
@@ -622,12 +687,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
622 | // If we didn't find a root, then just return whichever child we found, or null if none | 687 | // If we didn't find a root, then just return whichever child we found, or null if none |
623 | if (child == null) | 688 | if (child == null) |
624 | { | 689 | { |
625 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); | 690 | if (m_debugEnabled) |
691 | m_log.DebugFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); | ||
626 | } | 692 | } |
627 | else | 693 | else |
628 | { | 694 | { |
629 | if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); | 695 | if (m_debugEnabled) |
696 | m_log.DebugFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); | ||
630 | } | 697 | } |
698 | |||
631 | return child; | 699 | return child; |
632 | } | 700 | } |
633 | 701 | ||