aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs113
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs15
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs9
3 files changed, 107 insertions, 30 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 26b70a1..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,6 +274,8 @@ 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;
251 HashSet<string> attemptDeliveryUuidSet = null; 281 HashSet<string> attemptDeliveryUuidSet = null;
@@ -285,9 +315,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
285 m_log.DebugFormat( 315 m_log.DebugFormat(
286 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", 316 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members",
287 groupID, groupMembers.Count); 317 groupID, groupMembers.Count);
288 } 318 }
289
290 int requestStartTick = Environment.TickCount;
291 319
292 foreach (GroupMembersData member in groupMembers) 320 foreach (GroupMembersData member in groupMembers)
293 { 321 {
@@ -315,7 +343,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
315 343
316 // Copy Message 344 // Copy Message
317 GridInstantMessage msg = new GridInstantMessage(); 345 GridInstantMessage msg = new GridInstantMessage();
318 msg.imSessionID = groupID.Guid; 346 msg.imSessionID = im.imSessionID;
319 msg.fromAgentName = im.fromAgentName; 347 msg.fromAgentName = im.fromAgentName;
320 msg.message = im.message; 348 msg.message = im.message;
321 msg.dialog = im.dialog; 349 msg.dialog = im.dialog;
@@ -336,27 +364,45 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
336 IClientAPI client = GetActiveClient(member.AgentID); 364 IClientAPI client = GetActiveClient(member.AgentID);
337 if (client == null) 365 if (client == null)
338 { 366 {
367 int startTick = Environment.TickCount;
368
339 // If they're not local, forward across the grid 369 // If they're not local, forward across the grid
340 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
341 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); 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);
342 } 376 }
343 else 377 else
344 { 378 {
345 // Deliver locally, directly 379 int startTick = Environment.TickCount;
346 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); 380
347 ProcessMessageFromGroupSession(msg, client); 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);
348 } 388 }
349 } 389 }
350 else 390 else
351 { 391 {
392 int startTick = Environment.TickCount;
393
352 m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { }); 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);
353 } 400 }
354 } 401 }
355 402
356 // Temporary for assessing how long it still takes to send messages to large online groups. 403 if (m_debugEnabled)
357 if (m_messageOnlineAgentsOnly)
358 m_log.DebugFormat( 404 m_log.DebugFormat(
359 "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3}ms", 405 "[GROUPS-MESSAGING]: Total SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3} ms",
360 groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick); 406 groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick);
361 } 407 }
362 408
@@ -420,7 +466,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
420 466
421 private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) 467 private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
422 { 468 {
423 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);
424 473
425 UUID AgentID = new UUID(msg.fromAgentID); 474 UUID AgentID = new UUID(msg.fromAgentID);
426 UUID GroupID = new UUID(msg.imSessionID); 475 UUID GroupID = new UUID(msg.imSessionID);
@@ -588,15 +637,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
588 // Don't log any normal IMs (privacy!) 637 // Don't log any normal IMs (privacy!)
589 if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent) 638 if (m_debugEnabled && im.dialog != (byte)InstantMessageDialog.MessageFromAgent)
590 { 639 {
591 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");
592 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog); 641 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: Dialog({0})", (InstantMessageDialog)im.dialog);
593 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID); 642 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentID({0})", im.fromAgentID);
594 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName); 643 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: fromAgentName({0})", im.fromAgentName);
595 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID); 644 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: imSessionID({0})", im.imSessionID);
596 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message); 645 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: message({0})", im.message);
597 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline); 646 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: offline({0})", im.offline);
598 m_log.WarnFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID); 647 m_log.DebugFormat("[GROUPS-MESSAGING]: IM: toAgentID({0})", im.toAgentID);
599 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"));
600 } 649 }
601 } 650 }
602 651
@@ -607,7 +656,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
607 /// </summary> 656 /// </summary>
608 private IClientAPI GetActiveClient(UUID agentID) 657 private IClientAPI GetActiveClient(UUID agentID)
609 { 658 {
610 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);
611 661
612 IClientAPI child = null; 662 IClientAPI child = null;
613 663
@@ -619,12 +669,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
619 { 669 {
620 if (!sp.IsChildAgent) 670 if (!sp.IsChildAgent)
621 { 671 {
622 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
623 return sp.ControllingClient; 675 return sp.ControllingClient;
624 } 676 }
625 else 677 else
626 { 678 {
627 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
628 child = sp.ControllingClient; 682 child = sp.ControllingClient;
629 } 683 }
630 } 684 }
@@ -633,12 +687,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
633 // 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
634 if (child == null) 688 if (child == null)
635 { 689 {
636 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);
637 } 692 }
638 else 693 else
639 { 694 {
640 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);
641 } 697 }
698
642 return child; 699 return child;
643 } 700 }
644 701
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index f34152c..8a9e4d2 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -357,7 +357,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
357 357
358 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 358 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
359 { 359 {
360 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 360 if (m_debugEnabled)
361 m_log.DebugFormat(
362 "[GROUPS]: {0} called for {1}, message type {2}",
363 System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name, (InstantMessageDialog)im.dialog);
361 364
362 // Group invitations 365 // Group invitations
363 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 366 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
@@ -551,6 +554,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
551 554
552 UUID noticeID = new UUID(im.imSessionID); 555 UUID noticeID = new UUID(im.imSessionID);
553 556
557 if (m_debugEnabled)
558 m_log.DebugFormat("[GROUPS]: Requesting notice {0} for {1}", noticeID, remoteClient.AgentId);
559
554 GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID); 560 GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID);
555 if (notice != null) 561 if (notice != null)
556 { 562 {
@@ -572,6 +578,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
572 578
573 remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); 579 remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0);
574 } 580 }
581 else
582 {
583 if (m_debugEnabled)
584 m_log.DebugFormat(
585 "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.",
586 noticeID, remoteClient.AgentId);
587 }
575 } 588 }
576 589
577 // Interop, received special 210 code for ejecting a group member 590 // Interop, received special 210 code for ejecting a group member
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
index b5a10af..d944087 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
@@ -132,6 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
132 MessageTransferModule mtm = new MessageTransferModule(); 132 MessageTransferModule mtm = new MessageTransferModule();
133 GroupsModule gm = new GroupsModule(); 133 GroupsModule gm = new GroupsModule();
134 GroupsMessagingModule gmm = new GroupsMessagingModule(); 134 GroupsMessagingModule gmm = new GroupsMessagingModule();
135 MockGroupsServicesConnector mgsc = new MockGroupsServicesConnector();
135 136
136 IConfigSource configSource = new IniConfigSource(); 137 IConfigSource configSource = new IniConfigSource();
137 138
@@ -149,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
149 config.Set("MessagingEnabled", true); 150 config.Set("MessagingEnabled", true);
150 } 151 }
151 152
152 SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm); 153 SceneHelpers.SetupSceneModules(scene, configSource, mgsc, mtm, gm, gmm);
153 154
154 UUID userId = TestHelpers.ParseTail(0x1); 155 UUID userId = TestHelpers.ParseTail(0x1);
155 string subjectText = "newman"; 156 string subjectText = "newman";
@@ -185,6 +186,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
185 Assert.That(spReceivedMessages.Count, Is.EqualTo(1)); 186 Assert.That(spReceivedMessages.Count, Is.EqualTo(1));
186 Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage)); 187 Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage));
187 188
189 List<GroupNoticeData> notices = mgsc.GetGroupNotices(UUID.Zero, groupID);
190 Assert.AreEqual(1, notices.Count);
191
192 // OpenSimulator (possibly also SL) transport the notice ID as the session ID!
193 Assert.AreEqual(notices[0].NoticeID.Guid, spReceivedMessages[0].imSessionID);
194
188 Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0)); 195 Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0));
189 } 196 }
190 197