diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Friends')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs index 58251cb..72c64ad 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs | |||
@@ -36,6 +36,7 @@ using Nwc.XmlRpc; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications.Cache; | 37 | using OpenSim.Framework.Communications.Cache; |
38 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
39 | using OpenSim.Region.Interfaces; | ||
39 | using OpenSim.Region.Environment.Interfaces; | 40 | using OpenSim.Region.Environment.Interfaces; |
40 | using OpenSim.Region.Environment.Scenes; | 41 | using OpenSim.Region.Environment.Scenes; |
41 | 42 | ||
@@ -105,6 +106,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
105 | 106 | ||
106 | private Scene m_initialScene; // saves a lookup if we don't have a specific scene | 107 | private Scene m_initialScene; // saves a lookup if we don't have a specific scene |
107 | private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); | 108 | private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); |
109 | private IMessageTransferModule m_TransferModule = null; | ||
108 | 110 | ||
109 | #region IRegionModule Members | 111 | #region IRegionModule Members |
110 | 112 | ||
@@ -124,7 +126,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
124 | m_scenes[scene.RegionInfo.RegionHandle] = scene; | 126 | m_scenes[scene.RegionInfo.RegionHandle] = scene; |
125 | } | 127 | } |
126 | scene.EventManager.OnNewClient += OnNewClient; | 128 | scene.EventManager.OnNewClient += OnNewClient; |
127 | scene.EventManager.OnGridInstantMessage += OnGridInstantMessage; | 129 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
128 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | 130 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; |
129 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | 131 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; |
130 | scene.EventManager.OnClientClosed += ClientClosed; | 132 | scene.EventManager.OnClientClosed += ClientClosed; |
@@ -132,6 +134,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
132 | 134 | ||
133 | public void PostInitialise() | 135 | public void PostInitialise() |
134 | { | 136 | { |
137 | List<Scene> scenes = new List<Scene>(m_scenes.Values); | ||
138 | m_TransferModule = scenes[0].RequestModuleInterface<IMessageTransferModule>(); | ||
139 | if (m_TransferModule == null) | ||
140 | m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); | ||
135 | } | 141 | } |
136 | 142 | ||
137 | public void Close() | 143 | public void Close() |
@@ -434,11 +440,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
434 | // we don't want to get that new IM into here if we aren't local, as only on the destination | 440 | // we don't want to get that new IM into here if we aren't local, as only on the destination |
435 | // should receive it. If we *are* local, *we* are the destination, so we have to receive it. | 441 | // should receive it. If we *are* local, *we* are the destination, so we have to receive it. |
436 | // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here. | 442 | // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here. |
437 | InstantMessageReceiver recv = InstantMessageReceiver.IMModule; | ||
438 | if (GetAnyPresenceFromAgentID(toAgentID) != null) recv |= InstantMessageReceiver.FriendsModule; | ||
439 | 443 | ||
440 | // We don't really care which local scene we pipe it through. | 444 | // We don't really care which local scene we pipe it through. |
441 | m_initialScene.TriggerGridInstantMessage(msg, recv); | 445 | if (m_TransferModule != null) |
446 | { | ||
447 | m_TransferModule.SendInstantMessage(msg, | ||
448 | delegate(bool success) {} | ||
449 | ); | ||
450 | } | ||
442 | } | 451 | } |
443 | else | 452 | else |
444 | { | 453 | { |
@@ -531,17 +540,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
531 | } | 540 | } |
532 | } | 541 | } |
533 | 542 | ||
534 | private void OnGridInstantMessage(GridInstantMessage msg, InstantMessageReceiver whichModule) | 543 | private void OnGridInstantMessage(GridInstantMessage msg) |
535 | { | 544 | { |
536 | if ((whichModule & InstantMessageReceiver.FriendsModule) == 0) | 545 | // Just call the IM handler above |
537 | return; | 546 | // This event won't be raised unless we have that agent, |
538 | 547 | // so we can depend on the above not trying to send | |
539 | // Trigger the above event handler | 548 | // via grid again |
540 | OnInstantMessage(null, new UUID(msg.fromAgentID), new UUID(msg.fromAgentSession), | 549 | // |
541 | new UUID(msg.toAgentID), new UUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, | 550 | OnInstantMessage(null, new UUID(msg.fromAgentID), |
542 | msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, | 551 | new UUID(msg.fromAgentSession), |
543 | new Vector3(msg.Position.X, msg.Position.Y, msg.Position.Z), new UUID(msg.RegionID), | 552 | new UUID(msg.toAgentID), new UUID(msg.imSessionID), |
544 | msg.binaryBucket); | 553 | msg.timestamp, msg.fromAgentName, msg.message, |
554 | msg.dialog, msg.fromGroup, msg.offline, | ||
555 | msg.ParentEstateID, msg.Position, | ||
556 | new UUID(msg.RegionID), msg.binaryBucket); | ||
545 | } | 557 | } |
546 | 558 | ||
547 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID transactionID, List<UUID> callingCardFolders) | 559 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID transactionID, List<UUID> callingCardFolders) |
@@ -607,12 +619,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
607 | // we don't want to get that new IM into here if we aren't local, as only on the destination | 619 | // we don't want to get that new IM into here if we aren't local, as only on the destination |
608 | // should receive it. If we *are* local, *we* are the destination, so we have to receive it. | 620 | // should receive it. If we *are* local, *we* are the destination, so we have to receive it. |
609 | // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here. | 621 | // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here. |
610 | InstantMessageReceiver recv = InstantMessageReceiver.IMModule; | ||
611 | if (GetAnyPresenceFromAgentID(friendID) != null) recv |= InstantMessageReceiver.FriendsModule; | ||
612 | 622 | ||
613 | // now we have to inform the agent about the friend. For the opposite direction, this happens in the handler | 623 | // now we have to inform the agent about the friend. For the opposite direction, this happens in the handler |
614 | // of the type 39 IM | 624 | // of the type 39 IM |
615 | SceneAgentIn.TriggerGridInstantMessage(msg, recv); | 625 | if (m_TransferModule != null) |
626 | { | ||
627 | m_TransferModule.SendInstantMessage(msg, | ||
628 | delegate(bool success) {} | ||
629 | ); | ||
630 | } | ||
616 | 631 | ||
617 | // tell client that new friend is online | 632 | // tell client that new friend is online |
618 | client.SendAgentOnline(new UUID[] { friendID }); | 633 | client.SendAgentOnline(new UUID[] { friendID }); |
@@ -664,12 +679,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
664 | // we don't want to get that new IM into here if we aren't local, as only on the destination | 679 | // we don't want to get that new IM into here if we aren't local, as only on the destination |
665 | // should receive it. If we *are* local, *we* are the destination, so we have to receive it. | 680 | // should receive it. If we *are* local, *we* are the destination, so we have to receive it. |
666 | // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here. | 681 | // As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here. |
667 | InstantMessageReceiver recv = InstantMessageReceiver.IMModule; | ||
668 | if (GetAnyPresenceFromAgentID(friendID) != null) recv |= InstantMessageReceiver.FriendsModule; | ||
669 | 682 | ||
670 | // now we have to inform the agent about the friend. For the opposite direction, this happens in the handler | 683 | // now we have to inform the agent about the friend. For the opposite direction, this happens in the handler |
671 | // of the type 39 IM | 684 | // of the type 39 IM |
672 | SceneAgentIn.TriggerGridInstantMessage(msg, recv); | 685 | if (m_TransferModule != null) |
686 | { | ||
687 | m_TransferModule.SendInstantMessage(msg, | ||
688 | delegate(bool success) {} | ||
689 | ); | ||
690 | } | ||
673 | } | 691 | } |
674 | 692 | ||
675 | private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) | 693 | private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) |