diff options
Diffstat (limited to 'OpenSim/Region')
19 files changed, 922 insertions, 1053 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 580e06f..fceca8e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -44,109 +44,14 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
44 | 44 | ||
45 | namespace OpenSim.Region.CoreModules.Avatar.Friends | 45 | namespace OpenSim.Region.CoreModules.Avatar.Friends |
46 | { | 46 | { |
47 | /* | 47 | public class FriendsModule : ISharedRegionModule, IFriendsModule |
48 | This module handles adding/removing friends, and the the presence | ||
49 | notification process for login/logoff of friends. | ||
50 | |||
51 | The presence notification works as follows: | ||
52 | - After the user initially connects to a region (so we now have a UDP | ||
53 | connection to work with), this module fetches the friends of user | ||
54 | (those are cached), their on-/offline status, and info about the | ||
55 | region they are in from the MessageServer. | ||
56 | - (*) It then informs the user about the on-/offline status of her friends. | ||
57 | - It then informs all online friends currently on this region-server about | ||
58 | user's new online status (this will save some network traffic, as local | ||
59 | messages don't have to be transferred inter-region, and it will be all | ||
60 | that has to be done in Standalone Mode). | ||
61 | - For the rest of the online friends (those not on this region-server), | ||
62 | this module uses the provided region-information to map users to | ||
63 | regions, and sends one notification to every region containing the | ||
64 | friends to inform on that server. | ||
65 | - The region-server will handle that in the following way: | ||
66 | - If it finds the friend, it informs her about the user being online. | ||
67 | - If it doesn't find the friend (maybe she TPed away in the meantime), | ||
68 | it stores that information. | ||
69 | - After it processed all friends, it returns the list of friends it | ||
70 | couldn't find. | ||
71 | - If this list isn't empty, the FriendsModule re-requests information | ||
72 | about those online friends that have been missed and starts at (*) | ||
73 | again until all friends have been found, or until it tried 3 times | ||
74 | (to prevent endless loops due to some uncaught error). | ||
75 | |||
76 | NOTE: Online/Offline notifications don't need to be sent on region change. | ||
77 | |||
78 | We implement two XMLRpc handlers here, handling all the inter-region things | ||
79 | we have to handle: | ||
80 | - On-/Offline-Notifications (bulk) | ||
81 | - Terminate Friendship messages (single) | ||
82 | */ | ||
83 | |||
84 | public class FriendsModule : IRegionModule, IFriendsModule | ||
85 | { | 48 | { |
86 | private class Transaction | 49 | public void Initialise(IConfigSource config) |
87 | { | 50 | { |
88 | public UUID agentID; | ||
89 | public string agentName; | ||
90 | public uint count; | ||
91 | |||
92 | public Transaction(UUID agentID, string agentName) | ||
93 | { | ||
94 | this.agentID = agentID; | ||
95 | this.agentName = agentName; | ||
96 | this.count = 1; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
101 | |||
102 | private Cache m_friendLists = new Cache(CacheFlags.AllowUpdate); | ||
103 | |||
104 | private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>(); | ||
105 | |||
106 | private Dictionary<UUID, UUID> m_pendingCallingcardRequests = new Dictionary<UUID,UUID>(); | ||
107 | |||
108 | private Scene m_initialScene; // saves a lookup if we don't have a specific scene | ||
109 | private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); | ||
110 | private IMessageTransferModule m_TransferModule = null; | ||
111 | |||
112 | private IGridService m_gridServices = null; | ||
113 | |||
114 | #region IRegionModule Members | ||
115 | |||
116 | public void Initialise(Scene scene, IConfigSource config) | ||
117 | { | ||
118 | lock (m_scenes) | ||
119 | { | ||
120 | if (m_scenes.Count == 0) | ||
121 | { | ||
122 | MainServer.Instance.AddXmlRPCHandler("presence_update_bulk", processPresenceUpdateBulk); | ||
123 | MainServer.Instance.AddXmlRPCHandler("terminate_friend", processTerminateFriend); | ||
124 | m_friendLists.DefaultTTL = new TimeSpan(1, 0, 0); // store entries for one hour max | ||
125 | m_initialScene = scene; | ||
126 | } | ||
127 | |||
128 | if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle)) | ||
129 | m_scenes[scene.RegionInfo.RegionHandle] = scene; | ||
130 | } | ||
131 | |||
132 | scene.RegisterModuleInterface<IFriendsModule>(this); | ||
133 | |||
134 | scene.EventManager.OnNewClient += OnNewClient; | ||
135 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
136 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
137 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
138 | scene.EventManager.OnClientClosed += ClientClosed; | ||
139 | } | 51 | } |
140 | 52 | ||
141 | public void PostInitialise() | 53 | public void PostInitialise() |
142 | { | 54 | { |
143 | if (m_scenes.Count > 0) | ||
144 | { | ||
145 | m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); | ||
146 | m_gridServices = m_initialScene.GridService; | ||
147 | } | ||
148 | if (m_TransferModule == null) | ||
149 | m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); | ||
150 | } | 55 | } |
151 | 56 | ||
152 | public void Close() | 57 | public void Close() |
@@ -674,448 +579,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
674 | // ... and add the calling card | 579 | // ... and add the calling card |
675 | CreateCallingCard(initiator.ControllingClient, fromAgentID, folder.ID, fromName); | 580 | CreateCallingCard(initiator.ControllingClient, fromAgentID, folder.ID, fromName); |
676 | } | 581 | } |
582 | >>>>>>> master:OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | ||
677 | } | 583 | } |
678 | 584 | ||
679 | private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | 585 | public void AddRegion(Scene scene) |
680 | { | ||
681 | m_log.DebugFormat("[FRIEND]: Got approve friendship from {0} {1}, agentID {2}, tid {3}", | ||
682 | client.Name, client.AgentId, agentID, friendID); | ||
683 | |||
684 | // store the new friend persistently for both avatars | ||
685 | m_initialScene.StoreAddFriendship(friendID, agentID, (uint) FriendRights.CanSeeOnline); | ||
686 | |||
687 | // The cache entries aren't valid anymore either, as we just added a friend to both sides. | ||
688 | lock (m_friendLists) | ||
689 | { | ||
690 | m_friendLists.Invalidate(agentID.ToString()); | ||
691 | m_friendLists.Invalidate(friendID.ToString()); | ||
692 | } | ||
693 | |||
694 | // if it's a local friend, we don't have to do the lookup | ||
695 | ScenePresence friendPresence = GetAnyPresenceFromAgentID(friendID); | ||
696 | |||
697 | if (friendPresence != null) | ||
698 | { | ||
699 | m_log.Debug("[FRIEND]: Local agent detected."); | ||
700 | |||
701 | // create calling card | ||
702 | CreateCallingCard(client, friendID, callingCardFolders[0], friendPresence.Name); | ||
703 | |||
704 | // local message means OnGridInstantMessage won't be triggered, so do the work here. | ||
705 | friendPresence.ControllingClient.SendInstantMessage( | ||
706 | new GridInstantMessage(client.Scene, agentID, | ||
707 | client.Name, friendID, | ||
708 | (byte)InstantMessageDialog.FriendshipAccepted, | ||
709 | agentID.ToString(), false, Vector3.Zero)); | ||
710 | ApproveFriendship(agentID, friendID, client.Name); | ||
711 | } | ||
712 | else | ||
713 | { | ||
714 | m_log.Debug("[FRIEND]: Remote agent detected."); | ||
715 | |||
716 | // fetch the friend's name for the calling card. | ||
717 | CachedUserInfo info = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(friendID); | ||
718 | |||
719 | // create calling card | ||
720 | CreateCallingCard(client, friendID, callingCardFolders[0], | ||
721 | info.UserProfile.FirstName + " " + info.UserProfile.SurName); | ||
722 | |||
723 | // Compose (remote) response to friend. | ||
724 | GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, | ||
725 | (byte)InstantMessageDialog.FriendshipAccepted, | ||
726 | agentID.ToString(), false, Vector3.Zero); | ||
727 | if (m_TransferModule != null) | ||
728 | { | ||
729 | m_TransferModule.SendInstantMessage(msg, | ||
730 | delegate(bool success) { | ||
731 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
732 | } | ||
733 | ); | ||
734 | } | ||
735 | } | ||
736 | |||
737 | // tell client that new friend is online | ||
738 | client.SendAgentOnline(new UUID[] { friendID }); | ||
739 | } | ||
740 | |||
741 | private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List<UUID> callingCardFolders) | ||
742 | { | ||
743 | m_log.DebugFormat("[FRIEND]: Got deny friendship from {0} {1}, agentID {2}, tid {3}", | ||
744 | client.Name, client.AgentId, agentID, friendID); | ||
745 | |||
746 | // Compose response to other agent. | ||
747 | GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, | ||
748 | (byte)InstantMessageDialog.FriendshipDeclined, | ||
749 | agentID.ToString(), false, Vector3.Zero); | ||
750 | // send decline to initiator | ||
751 | if (m_TransferModule != null) | ||
752 | { | ||
753 | m_TransferModule.SendInstantMessage(msg, | ||
754 | delegate(bool success) { | ||
755 | m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); | ||
756 | } | ||
757 | ); | ||
758 | } | ||
759 | } | ||
760 | |||
761 | private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) | ||
762 | { | ||
763 | // client.AgentId == agentID! | ||
764 | |||
765 | // this removes the friends from the stored friendlists. After the next login, they will be gone... | ||
766 | m_initialScene.StoreRemoveFriendship(agentID, exfriendID); | ||
767 | |||
768 | // ... now tell the two involved clients that they aren't friends anymore. | ||
769 | |||
770 | // I don't know why we have to tell <agent>, as this was caused by her, but that's how it works in SL... | ||
771 | client.SendTerminateFriend(exfriendID); | ||
772 | |||
773 | // now send the friend, if online | ||
774 | ScenePresence presence = GetAnyPresenceFromAgentID(exfriendID); | ||
775 | if (presence != null) | ||
776 | { | ||
777 | m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", agentID, exfriendID); | ||
778 | presence.ControllingClient.SendTerminateFriend(agentID); | ||
779 | } | ||
780 | else | ||
781 | { | ||
782 | // retry 3 times, in case the agent TPed from the last known region... | ||
783 | for (int retry = 0; retry < 3; ++retry) | ||
784 | { | ||
785 | // wasn't sent, so ex-friend wasn't around on this region-server. Fetch info and try to send | ||
786 | UserAgentData data = m_initialScene.CommsManager.UserService.GetAgentByUUID(exfriendID); | ||
787 | |||
788 | if (null == data) | ||
789 | break; | ||
790 | |||
791 | if (!data.AgentOnline) | ||
792 | { | ||
793 | m_log.DebugFormat("[FRIEND]: {0} is offline, so not sending TerminateFriend", exfriendID); | ||
794 | break; // if ex-friend isn't online, we don't need to send | ||
795 | } | ||
796 | |||
797 | m_log.DebugFormat("[FRIEND]: Sending remote terminate friend {0} to agent {1}@{2}", | ||
798 | agentID, exfriendID, data.Handle); | ||
799 | |||
800 | // try to send to foreign region, retry if it fails (friend TPed away, for example) | ||
801 | if (TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; | ||
802 | } | ||
803 | } | ||
804 | |||
805 | // clean up cache: FriendList is wrong now... | ||
806 | lock (m_friendLists) | ||
807 | { | ||
808 | m_friendLists.Invalidate(agentID.ToString()); | ||
809 | m_friendLists.Invalidate(exfriendID.ToString()); | ||
810 | } | ||
811 | } | ||
812 | |||
813 | #endregion | ||
814 | |||
815 | #region CallingCards | ||
816 | |||
817 | private void OnOfferCallingCard(IClientAPI client, UUID destID, UUID transactionID) | ||
818 | { | 586 | { |
819 | m_log.DebugFormat("[CALLING CARD]: got offer from {0} for {1}, transaction {2}", | ||
820 | client.AgentId, destID, transactionID); | ||
821 | // This might be slightly wrong. On a multi-region server, we might get the child-agent instead of the root-agent | ||
822 | // (or the root instead of the child) | ||
823 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
824 | if (destAgent == null) | ||
825 | { | ||
826 | client.SendAlertMessage("The person you have offered a card to can't be found anymore."); | ||
827 | return; | ||
828 | } | ||
829 | |||
830 | lock (m_pendingCallingcardRequests) | ||
831 | { | ||
832 | m_pendingCallingcardRequests[transactionID] = client.AgentId; | ||
833 | } | ||
834 | // inform the destination agent about the offer | ||
835 | destAgent.ControllingClient.SendOfferCallingCard(client.AgentId, transactionID); | ||
836 | } | 587 | } |
837 | 588 | ||
838 | private void CreateCallingCard(IClientAPI client, UUID creator, UUID folder, string name) | 589 | public void RegionLoaded(Scene scene) |
839 | { | 590 | { |
840 | InventoryItemBase item = new InventoryItemBase(); | ||
841 | item.AssetID = UUID.Zero; | ||
842 | item.AssetType = (int)AssetType.CallingCard; | ||
843 | item.BasePermissions = (uint)PermissionMask.Copy; | ||
844 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
845 | item.CreatorId = creator.ToString(); | ||
846 | item.CurrentPermissions = item.BasePermissions; | ||
847 | item.Description = ""; | ||
848 | item.EveryOnePermissions = (uint)PermissionMask.None; | ||
849 | item.Flags = 0; | ||
850 | item.Folder = folder; | ||
851 | item.GroupID = UUID.Zero; | ||
852 | item.GroupOwned = false; | ||
853 | item.ID = UUID.Random(); | ||
854 | item.InvType = (int)InventoryType.CallingCard; | ||
855 | item.Name = name; | ||
856 | item.NextPermissions = item.EveryOnePermissions; | ||
857 | item.Owner = client.AgentId; | ||
858 | item.SalePrice = 10; | ||
859 | item.SaleType = (byte)SaleType.Not; | ||
860 | ((Scene)client.Scene).AddInventoryItem(client, item); | ||
861 | } | 591 | } |
862 | 592 | ||
863 | private void OnAcceptCallingCard(IClientAPI client, UUID transactionID, UUID folderID) | 593 | public void RemoveRegion(Scene scene) |
864 | { | 594 | { |
865 | m_log.DebugFormat("[CALLING CARD]: User {0} ({1} {2}) accepted tid {3}, folder {4}", | ||
866 | client.AgentId, | ||
867 | client.FirstName, client.LastName, | ||
868 | transactionID, folderID); | ||
869 | UUID destID; | ||
870 | lock (m_pendingCallingcardRequests) | ||
871 | { | ||
872 | if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) | ||
873 | { | ||
874 | m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", | ||
875 | client.Name); | ||
876 | return; | ||
877 | } | ||
878 | // else found pending calling card request with that transaction. | ||
879 | m_pendingCallingcardRequests.Remove(transactionID); | ||
880 | } | ||
881 | |||
882 | |||
883 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
884 | // inform sender of the card that destination declined the offer | ||
885 | if (destAgent != null) destAgent.ControllingClient.SendAcceptCallingCard(transactionID); | ||
886 | |||
887 | // put a calling card into the inventory of receiver | ||
888 | CreateCallingCard(client, destID, folderID, destAgent.Name); | ||
889 | } | 595 | } |
890 | 596 | ||
891 | private void OnDeclineCallingCard(IClientAPI client, UUID transactionID) | 597 | public void Close() |
892 | { | 598 | { |
893 | m_log.DebugFormat("[CALLING CARD]: User {0} (ID:{1}) declined card, tid {2}", | ||
894 | client.Name, client.AgentId, transactionID); | ||
895 | UUID destID; | ||
896 | lock (m_pendingCallingcardRequests) | ||
897 | { | ||
898 | if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) | ||
899 | { | ||
900 | m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", | ||
901 | client.Name); | ||
902 | return; | ||
903 | } | ||
904 | // else found pending calling card request with that transaction. | ||
905 | m_pendingCallingcardRequests.Remove(transactionID); | ||
906 | } | ||
907 | |||
908 | ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); | ||
909 | // inform sender of the card that destination declined the offer | ||
910 | if (destAgent != null) destAgent.ControllingClient.SendDeclineCallingCard(transactionID); | ||
911 | } | 599 | } |
912 | 600 | ||
913 | /// <summary> | 601 | public string Name |
914 | /// Send presence information about a client to other clients in both this region and others. | ||
915 | /// </summary> | ||
916 | /// <param name="client"></param> | ||
917 | /// <param name="friendList"></param> | ||
918 | /// <param name="iAmOnline"></param> | ||
919 | private void SendPresenceState(IClientAPI client, List<FriendListItem> friendList, bool iAmOnline) | ||
920 | { | 602 | { |
921 | //m_log.DebugFormat("[FRIEND]: {0} logged {1}; sending presence updates", client.Name, iAmOnline ? "in" : "out"); | 603 | get { return "FriendsModule"; } |
922 | |||
923 | if (friendList == null || friendList.Count == 0) | ||
924 | { | ||
925 | //m_log.DebugFormat("[FRIEND]: {0} doesn't have friends.", client.Name); | ||
926 | return; // nothing we can do if she doesn't have friends... | ||
927 | } | ||
928 | |||
929 | // collect sets of friendIDs; to send to (online and offline), and to receive from | ||
930 | // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets. | ||
931 | // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago... | ||
932 | List<UUID> friendIDsToSendTo = new List<UUID>(); | ||
933 | List<UUID> candidateFriendIDsToReceive = new List<UUID>(); | ||
934 | |||
935 | foreach (FriendListItem item in friendList) | ||
936 | { | ||
937 | if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0) | ||
938 | { | ||
939 | // friend is allowed to see my presence => add | ||
940 | if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
941 | friendIDsToSendTo.Add(item.Friend); | ||
942 | |||
943 | if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
944 | candidateFriendIDsToReceive.Add(item.Friend); | ||
945 | } | ||
946 | } | ||
947 | |||
948 | // we now have a list of "interesting" friends (which we have to find out on-/offline state for), | ||
949 | // friends we want to send our online state to (if *they* are online, too), and | ||
950 | // friends we want to receive online state for (currently unknown whether online or not) | ||
951 | |||
952 | // as this processing might take some time and friends might TP away, we try up to three times to | ||
953 | // reach them. Most of the time, we *will* reach them, and this loop won't loop | ||
954 | int retry = 0; | ||
955 | do | ||
956 | { | ||
957 | // build a list of friends to look up region-information and on-/offline-state for | ||
958 | List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo); | ||
959 | foreach (UUID uuid in candidateFriendIDsToReceive) | ||
960 | { | ||
961 | if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid); | ||
962 | } | ||
963 | |||
964 | m_log.DebugFormat( | ||
965 | "[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}", | ||
966 | friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name); | ||
967 | |||
968 | // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't | ||
969 | // necessarily contain the correct online state... | ||
970 | Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup); | ||
971 | m_log.DebugFormat( | ||
972 | "[FRIEND]: Found {0} regionInfos for {1} friends of {2}", | ||
973 | friendRegions.Count, friendIDsToLookup.Count, client.Name); | ||
974 | |||
975 | // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops. | ||
976 | UUID[] agentArr = new UUID[] { client.AgentId }; | ||
977 | |||
978 | // first, send to friend presence state to me, if I'm online... | ||
979 | if (iAmOnline) | ||
980 | { | ||
981 | List<UUID> friendIDsToReceive = new List<UUID>(); | ||
982 | |||
983 | for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i) | ||
984 | { | ||
985 | UUID uuid = candidateFriendIDsToReceive[i]; | ||
986 | FriendRegionInfo info; | ||
987 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) | ||
988 | { | ||
989 | friendIDsToReceive.Add(uuid); | ||
990 | } | ||
991 | } | ||
992 | |||
993 | m_log.DebugFormat( | ||
994 | "[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name); | ||
995 | |||
996 | if (friendIDsToReceive.Count > 0) | ||
997 | client.SendAgentOnline(friendIDsToReceive.ToArray()); | ||
998 | |||
999 | // clear them for a possible second iteration; we don't have to repeat this | ||
1000 | candidateFriendIDsToReceive.Clear(); | ||
1001 | } | ||
1002 | |||
1003 | // now, send my presence state to my friends | ||
1004 | for (int i = friendIDsToSendTo.Count - 1; i >= 0; --i) | ||
1005 | { | ||
1006 | UUID uuid = friendIDsToSendTo[i]; | ||
1007 | FriendRegionInfo info; | ||
1008 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) | ||
1009 | { | ||
1010 | // any client is good enough, root or child... | ||
1011 | ScenePresence agent = GetAnyPresenceFromAgentID(uuid); | ||
1012 | if (agent != null) | ||
1013 | { | ||
1014 | //m_log.DebugFormat("[FRIEND]: Found local agent {0}", agent.Name); | ||
1015 | |||
1016 | // friend is online and on this server... | ||
1017 | if (iAmOnline) agent.ControllingClient.SendAgentOnline(agentArr); | ||
1018 | else agent.ControllingClient.SendAgentOffline(agentArr); | ||
1019 | |||
1020 | // done, remove it | ||
1021 | friendIDsToSendTo.RemoveAt(i); | ||
1022 | } | ||
1023 | } | ||
1024 | else | ||
1025 | { | ||
1026 | //m_log.DebugFormat("[FRIEND]: Friend {0} ({1}) is offline; not sending.", uuid, i); | ||
1027 | |||
1028 | // friend is offline => no need to try sending | ||
1029 | friendIDsToSendTo.RemoveAt(i); | ||
1030 | } | ||
1031 | } | ||
1032 | |||
1033 | m_log.DebugFormat("[FRIEND]: Have {0} friends to contact via inter-region comms.", friendIDsToSendTo.Count); | ||
1034 | |||
1035 | // we now have all the friends left that are online (we think), but not on this region-server | ||
1036 | if (friendIDsToSendTo.Count > 0) | ||
1037 | { | ||
1038 | // sort them into regions | ||
1039 | Dictionary<ulong, List<UUID>> friendsInRegion = new Dictionary<ulong,List<UUID>>(); | ||
1040 | foreach (UUID uuid in friendIDsToSendTo) | ||
1041 | { | ||
1042 | ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already | ||
1043 | List<UUID> friends; | ||
1044 | if (!friendsInRegion.TryGetValue(handle, out friends)) | ||
1045 | { | ||
1046 | friends = new List<UUID>(); | ||
1047 | friendsInRegion[handle] = friends; | ||
1048 | } | ||
1049 | friends.Add(uuid); | ||
1050 | } | ||
1051 | m_log.DebugFormat("[FRIEND]: Found {0} regions to send to.", friendRegions.Count); | ||
1052 | |||
1053 | // clear uuids list and collect missed friends in it for the next retry | ||
1054 | friendIDsToSendTo.Clear(); | ||
1055 | |||
1056 | // send bulk updates to the region | ||
1057 | foreach (KeyValuePair<ulong, List<UUID>> pair in friendsInRegion) | ||
1058 | { | ||
1059 | //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line", | ||
1060 | // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off"); | ||
1061 | |||
1062 | friendIDsToSendTo.AddRange(InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline)); | ||
1063 | } | ||
1064 | } | ||
1065 | // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them. | ||
1066 | // In most cases, it will be empty, and it won't loop here. But sometimes, we have to work harder and try again... | ||
1067 | } | ||
1068 | while (++retry < 3 && friendIDsToSendTo.Count > 0); | ||
1069 | } | 604 | } |
1070 | 605 | ||
1071 | private void OnEconomyDataRequest(UUID agentID) | 606 | public Type ReplaceableInterface |
1072 | { | 607 | { |
1073 | // KLUDGE: This is the only way I found to get a message (only) after login was completed and the | 608 | get { return null; } |
1074 | // client is connected enough to receive UDP packets). | ||
1075 | // This packet seems to be sent only once, just after connection was established to the first | ||
1076 | // region after login. | ||
1077 | // We use it here to trigger a presence update; the old update-on-login was never be heard by | ||
1078 | // the freshly logged in viewer, as it wasn't connected to the region at that time. | ||
1079 | // TODO: Feel free to replace this by a better solution if you find one. | ||
1080 | |||
1081 | // get the agent. This should work every time, as we just got a packet from it | ||
1082 | //ScenePresence agent = GetRootPresenceFromAgentID(agentID); | ||
1083 | // KLUDGE 2: As this is sent quite early, the avatar isn't here as root agent yet. So, we have to cheat a bit | ||
1084 | ScenePresence agent = GetAnyPresenceFromAgentID(agentID); | ||
1085 | |||
1086 | // just to be paranoid... | ||
1087 | if (agent == null) | ||
1088 | { | ||
1089 | m_log.ErrorFormat("[FRIEND]: Got a packet from agent {0} who can't be found anymore!?", agentID); | ||
1090 | return; | ||
1091 | } | ||
1092 | |||
1093 | List<FriendListItem> fl; | ||
1094 | lock (m_friendLists) | ||
1095 | { | ||
1096 | fl = (List<FriendListItem>)m_friendLists.Get(agent.ControllingClient.AgentId.ToString(), | ||
1097 | m_initialScene.GetFriendList); | ||
1098 | } | ||
1099 | |||
1100 | // tell everyone that we are online | ||
1101 | SendPresenceState(agent.ControllingClient, fl, true); | ||
1102 | } | 609 | } |
1103 | 610 | ||
1104 | private void OnLogout(IClientAPI remoteClient) | 611 | public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, |
612 | string offerMessage) | ||
1105 | { | 613 | { |
1106 | List<FriendListItem> fl; | ||
1107 | lock (m_friendLists) | ||
1108 | { | ||
1109 | fl = (List<FriendListItem>)m_friendLists.Get(remoteClient.AgentId.ToString(), | ||
1110 | m_initialScene.GetFriendList); | ||
1111 | } | ||
1112 | |||
1113 | // tell everyone that we are offline | ||
1114 | SendPresenceState(remoteClient, fl, false); | ||
1115 | } | ||
1116 | private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) | ||
1117 | { | ||
1118 | ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); | ||
1119 | } | 614 | } |
1120 | public void FindAgent(IClientAPI remoteClient, UUID hunter, UUID target) | 615 | public void FindAgent(IClientAPI remoteClient, UUID hunter, UUID target) |
1121 | { | 616 | { |
@@ -1140,15 +635,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
1140 | 635 | ||
1141 | public List<FriendListItem> GetUserFriends(UUID agentID) | 636 | public List<FriendListItem> GetUserFriends(UUID agentID) |
1142 | { | 637 | { |
1143 | List<FriendListItem> fl; | 638 | return null; |
1144 | lock (m_friendLists) | ||
1145 | { | ||
1146 | fl = (List<FriendListItem>)m_friendLists.Get(agentID.ToString(), | ||
1147 | m_initialScene.GetFriendList); | ||
1148 | } | ||
1149 | |||
1150 | return fl; | ||
1151 | } | 639 | } |
1152 | } | 640 | } |
1153 | #endregion | ||
1154 | } | 641 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index 9a68749..ab141eb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -24,6 +24,7 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
@@ -36,9 +37,10 @@ using OpenSim.Region.Framework.Scenes; | |||
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 38 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
38 | { | 39 | { |
39 | public class InstantMessageModule : IRegionModule | 40 | public class InstantMessageModule : ISharedRegionModule |
40 | { | 41 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger( |
43 | MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | 44 | ||
43 | /// <value> | 45 | /// <value> |
44 | /// Is this module enabled? | 46 | /// Is this module enabled? |
@@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
51 | 53 | ||
52 | private IMessageTransferModule m_TransferModule = null; | 54 | private IMessageTransferModule m_TransferModule = null; |
53 | 55 | ||
54 | public void Initialise(Scene scene, IConfigSource config) | 56 | public void Initialise(IConfigSource config) |
55 | { | 57 | { |
56 | if (config.Configs["Messaging"] != null) | 58 | if (config.Configs["Messaging"] != null) |
57 | { | 59 | { |
@@ -62,6 +64,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
62 | } | 64 | } |
63 | 65 | ||
64 | m_enabled = true; | 66 | m_enabled = true; |
67 | } | ||
68 | |||
69 | public void AddRegion(Scene scene) | ||
70 | { | ||
71 | if (!m_enabled) | ||
72 | return; | ||
65 | 73 | ||
66 | lock (m_scenes) | 74 | lock (m_scenes) |
67 | { | 75 | { |
@@ -74,6 +82,39 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
74 | } | 82 | } |
75 | } | 83 | } |
76 | 84 | ||
85 | public void RegionLoaded(Scene scene) | ||
86 | { | ||
87 | if (!m_enabled) | ||
88 | return; | ||
89 | |||
90 | if (m_TransferModule == null) | ||
91 | { | ||
92 | m_TransferModule = | ||
93 | scene.RequestModuleInterface<IMessageTransferModule>(); | ||
94 | |||
95 | if (m_TransferModule == null) | ||
96 | { | ||
97 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, IM will not work!"); | ||
98 | scene.EventManager.OnClientConnect -= OnClientConnect; | ||
99 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
100 | |||
101 | m_scenes.Clear(); | ||
102 | m_enabled = false; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public void RemoveRegion(Scene scene) | ||
108 | { | ||
109 | if (!m_enabled) | ||
110 | return; | ||
111 | |||
112 | lock (m_scenes) | ||
113 | { | ||
114 | m_scenes.Remove(scene); | ||
115 | } | ||
116 | } | ||
117 | |||
77 | void OnClientConnect(IClientCore client) | 118 | void OnClientConnect(IClientCore client) |
78 | { | 119 | { |
79 | IClientIM clientIM; | 120 | IClientIM clientIM; |
@@ -85,15 +126,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
85 | 126 | ||
86 | public void PostInitialise() | 127 | public void PostInitialise() |
87 | { | 128 | { |
88 | if (!m_enabled) | ||
89 | return; | ||
90 | |||
91 | m_TransferModule = | ||
92 | m_scenes[0].RequestModuleInterface<IMessageTransferModule>(); | ||
93 | |||
94 | if (m_TransferModule == null) | ||
95 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ | ||
96 | "IM will not work!"); | ||
97 | } | 129 | } |
98 | 130 | ||
99 | public void Close() | 131 | public void Close() |
@@ -105,9 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
105 | get { return "InstantMessageModule"; } | 137 | get { return "InstantMessageModule"; } |
106 | } | 138 | } |
107 | 139 | ||
108 | public bool IsSharedModule | 140 | public Type ReplaceableInterface |
109 | { | 141 | { |
110 | get { return true; } | 142 | get { return null; } |
111 | } | 143 | } |
112 | 144 | ||
113 | #endregion | 145 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index e5159b3..2d4b421 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -40,18 +40,17 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public class MessageTransferModule : IRegionModule, IMessageTransferModule | 43 | public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | // private bool m_Enabled = false; | 47 | private bool m_Enabled = false; |
48 | protected bool m_Gridmode = false; | ||
49 | protected List<Scene> m_Scenes = new List<Scene>(); | 48 | protected List<Scene> m_Scenes = new List<Scene>(); |
50 | protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); | 49 | protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); |
51 | 50 | ||
52 | public event UndeliveredMessage OnUndeliveredMessage; | 51 | public event UndeliveredMessage OnUndeliveredMessage; |
53 | 52 | ||
54 | public virtual void Initialise(Scene scene, IConfigSource config) | 53 | public virtual void Initialise(IConfigSource config) |
55 | { | 54 | { |
56 | IConfig cnf = config.Configs["Messaging"]; | 55 | IConfig cnf = config.Configs["Messaging"]; |
57 | if (cnf != null && cnf.GetString( | 56 | if (cnf != null && cnf.GetString( |
@@ -62,20 +61,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
62 | return; | 61 | return; |
63 | } | 62 | } |
64 | 63 | ||
65 | cnf = config.Configs["Startup"]; | 64 | m_Enabled = true; |
66 | if (cnf != null) | 65 | } |
67 | m_Gridmode = cnf.GetBoolean("gridmode", false); | ||
68 | 66 | ||
69 | // m_Enabled = true; | 67 | public virtual void AddRegion(Scene scene) |
68 | { | ||
69 | if (!m_Enabled) | ||
70 | return; | ||
70 | 71 | ||
71 | lock (m_Scenes) | 72 | lock (m_Scenes) |
72 | { | 73 | { |
73 | if (m_Scenes.Count == 0) | ||
74 | { | ||
75 | MainServer.Instance.AddXmlRPCHandler( | ||
76 | "grid_instant_message", processXMLRPCGridInstantMessage); | ||
77 | } | ||
78 | |||
79 | m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); | 74 | m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); |
80 | scene.RegisterModuleInterface<IMessageTransferModule>(this); | 75 | scene.RegisterModuleInterface<IMessageTransferModule>(this); |
81 | m_Scenes.Add(scene); | 76 | m_Scenes.Add(scene); |
@@ -84,6 +79,26 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
84 | 79 | ||
85 | public virtual void PostInitialise() | 80 | public virtual void PostInitialise() |
86 | { | 81 | { |
82 | if (!m_Enabled) | ||
83 | return; | ||
84 | |||
85 | MainServer.Instance.AddXmlRPCHandler( | ||
86 | "grid_instant_message", processXMLRPCGridInstantMessage); | ||
87 | } | ||
88 | |||
89 | public virtual void RegionLoaded(Scene scene) | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public virtual void RemoveRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | lock(m_Scenes) | ||
99 | { | ||
100 | m_Scenes.Remove(scene); | ||
101 | } | ||
87 | } | 102 | } |
88 | 103 | ||
89 | public virtual void Close() | 104 | public virtual void Close() |
@@ -95,9 +110,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
95 | get { return "MessageTransferModule"; } | 110 | get { return "MessageTransferModule"; } |
96 | } | 111 | } |
97 | 112 | ||
98 | public virtual bool IsSharedModule | 113 | public virtual Type ReplaceableInterface |
99 | { | 114 | { |
100 | get { return true; } | 115 | get { return null; } |
101 | } | 116 | } |
102 | 117 | ||
103 | public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) | 118 | public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) |
@@ -148,15 +163,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
148 | } | 163 | } |
149 | } | 164 | } |
150 | 165 | ||
151 | if (m_Gridmode) | 166 | SendGridInstantMessageViaXMLRPC(im, result); |
152 | { | ||
153 | //m_log.DebugFormat("[INSTANT MESSAGE]: Delivering via grid"); | ||
154 | // Still here, try send via Grid | ||
155 | SendGridInstantMessageViaXMLRPC(im, result); | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | HandleUndeliveredMessage(im, result); | ||
160 | 167 | ||
161 | return; | 168 | return; |
162 | } | 169 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs index 2d4a635..24cbaeb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | |||
@@ -37,9 +37,9 @@ using OpenSim.Framework.Client; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.MuteList | 40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 41 | { |
42 | public class MuteListModule : IRegionModule | 42 | public class MuteListModule : ISharedRegionModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
@@ -47,11 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
47 | private List<Scene> m_SceneList = new List<Scene>(); | 47 | private List<Scene> m_SceneList = new List<Scene>(); |
48 | private string m_RestURL = String.Empty; | 48 | private string m_RestURL = String.Empty; |
49 | 49 | ||
50 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(IConfigSource config) |
51 | { | 51 | { |
52 | if (!enabled) | ||
53 | return; | ||
54 | |||
55 | IConfig cnf = config.Configs["Messaging"]; | 52 | IConfig cnf = config.Configs["Messaging"]; |
56 | if (cnf == null) | 53 | if (cnf == null) |
57 | { | 54 | { |
@@ -59,39 +56,53 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
59 | return; | 56 | return; |
60 | } | 57 | } |
61 | 58 | ||
62 | if (cnf != null && cnf.GetString( | 59 | if (cnf != null && cnf.GetString("MuteListModule", "None") != |
63 | "MuteListModule", "None") != | ||
64 | "MuteListModule") | 60 | "MuteListModule") |
65 | { | 61 | { |
66 | enabled = false; | 62 | enabled = false; |
67 | return; | 63 | return; |
68 | } | 64 | } |
69 | 65 | ||
66 | m_RestURL = cnf.GetString("MuteListURL", ""); | ||
67 | if (m_RestURL == "") | ||
68 | { | ||
69 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
70 | enabled = false; | ||
71 | return; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void AddRegion(Scene scene) | ||
76 | { | ||
77 | if (!enabled) | ||
78 | return; | ||
79 | |||
70 | lock (m_SceneList) | 80 | lock (m_SceneList) |
71 | { | 81 | { |
72 | if (m_SceneList.Count == 0) | 82 | m_SceneList.Add(scene); |
73 | { | ||
74 | m_RestURL = cnf.GetString("MuteListURL", ""); | ||
75 | if (m_RestURL == "") | ||
76 | { | ||
77 | m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); | ||
78 | enabled = false; | ||
79 | return; | ||
80 | } | ||
81 | } | ||
82 | if (!m_SceneList.Contains(scene)) | ||
83 | m_SceneList.Add(scene); | ||
84 | 83 | ||
85 | scene.EventManager.OnNewClient += OnNewClient; | 84 | scene.EventManager.OnNewClient += OnNewClient; |
86 | } | 85 | } |
87 | } | 86 | } |
88 | 87 | ||
89 | public void PostInitialise() | 88 | public void RegionLoaded(Scene scene) |
89 | { | ||
90 | } | ||
91 | |||
92 | public void RemoveRegion(Scene scene) | ||
90 | { | 93 | { |
91 | if (!enabled) | 94 | if (!enabled) |
92 | return; | 95 | return; |
93 | 96 | ||
94 | if (m_SceneList.Count == 0) | 97 | lock (m_SceneList) |
98 | { | ||
99 | m_SceneList.Remove(scene); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public void PostInitialise() | ||
104 | { | ||
105 | if (!enabled) | ||
95 | return; | 106 | return; |
96 | 107 | ||
97 | m_log.Debug("[MUTE LIST] Mute list enabled"); | 108 | m_log.Debug("[MUTE LIST] Mute list enabled"); |
@@ -102,26 +113,15 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList | |||
102 | get { return "MuteListModule"; } | 113 | get { return "MuteListModule"; } |
103 | } | 114 | } |
104 | 115 | ||
105 | public bool IsSharedModule | 116 | public Type ReplaceableInterface |
106 | { | 117 | { |
107 | get { return true; } | 118 | get { return null; } |
108 | } | 119 | } |
109 | 120 | ||
110 | public void Close() | 121 | public void Close() |
111 | { | 122 | { |
112 | } | 123 | } |
113 | 124 | ||
114 | // private IClientAPI FindClient(UUID agentID) | ||
115 | // { | ||
116 | // foreach (Scene s in m_SceneList) | ||
117 | // { | ||
118 | // ScenePresence presence = s.GetScenePresence(agentID); | ||
119 | // if (presence != null && !presence.IsChildAgent) | ||
120 | // return presence.ControllingClient; | ||
121 | // } | ||
122 | // return null; | ||
123 | // } | ||
124 | |||
125 | private void OnNewClient(IClientAPI client) | 125 | private void OnNewClient(IClientAPI client) |
126 | { | 126 | { |
127 | client.OnMuteListRequest += OnMuteListRequest; | 127 | client.OnMuteListRequest += OnMuteListRequest; |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 1614b70..a835c52 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -40,78 +40,88 @@ using OpenSim.Region.Framework.Scenes; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public class OfflineMessageModule : IRegionModule | 43 | public class OfflineMessageModule : ISharedRegionModule |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private bool enabled = true; | 47 | private bool enabled = true; |
48 | private List<Scene> m_SceneList = new List<Scene>(); | 48 | private List<Scene> m_SceneList = new List<Scene>(); |
49 | private string m_RestURL = String.Empty; | 49 | private string m_RestURL = String.Empty; |
50 | IMessageTransferModule m_TransferModule = null; | ||
50 | 51 | ||
51 | public void Initialise(Scene scene, IConfigSource config) | 52 | public void Initialise(IConfigSource config) |
52 | { | 53 | { |
53 | if (!enabled) | ||
54 | return; | ||
55 | |||
56 | IConfig cnf = config.Configs["Messaging"]; | 54 | IConfig cnf = config.Configs["Messaging"]; |
57 | if (cnf == null) | 55 | if (cnf == null) |
58 | { | 56 | { |
59 | enabled = false; | 57 | enabled = false; |
60 | return; | 58 | return; |
61 | } | 59 | } |
62 | if (cnf != null && cnf.GetString( | 60 | if (cnf != null && cnf.GetString("OfflineMessageModule", "None") != |
63 | "OfflineMessageModule", "None") != | ||
64 | "OfflineMessageModule") | 61 | "OfflineMessageModule") |
65 | { | 62 | { |
66 | enabled = false; | 63 | enabled = false; |
67 | return; | 64 | return; |
68 | } | 65 | } |
69 | 66 | ||
67 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
68 | if (m_RestURL == "") | ||
69 | { | ||
70 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
71 | enabled = false; | ||
72 | return; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public void AddRegion(Scene scene) | ||
77 | { | ||
78 | if (!enabled) | ||
79 | return; | ||
80 | |||
70 | lock (m_SceneList) | 81 | lock (m_SceneList) |
71 | { | 82 | { |
72 | if (m_SceneList.Count == 0) | 83 | m_SceneList.Add(scene); |
73 | { | ||
74 | m_RestURL = cnf.GetString("OfflineMessageURL", ""); | ||
75 | if (m_RestURL == "") | ||
76 | { | ||
77 | m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); | ||
78 | enabled = false; | ||
79 | return; | ||
80 | } | ||
81 | } | ||
82 | if (!m_SceneList.Contains(scene)) | ||
83 | m_SceneList.Add(scene); | ||
84 | 84 | ||
85 | scene.EventManager.OnNewClient += OnNewClient; | 85 | scene.EventManager.OnNewClient += OnNewClient; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | public void PostInitialise() | 89 | public void RegionLoaded(Scene scene) |
90 | { | 90 | { |
91 | if (!enabled) | 91 | if (!enabled) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | if (m_SceneList.Count == 0) | 94 | if (m_TransferModule == null) |
95 | return; | ||
96 | |||
97 | IMessageTransferModule trans = m_SceneList[0].RequestModuleInterface<IMessageTransferModule>(); | ||
98 | if (trans == null) | ||
99 | { | 95 | { |
100 | enabled = false; | 96 | m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>(); |
101 | 97 | if (m_TransferModule == null) | |
102 | lock (m_SceneList) | ||
103 | { | 98 | { |
104 | foreach (Scene s in m_SceneList) | 99 | scene.EventManager.OnNewClient -= OnNewClient; |
105 | s.EventManager.OnNewClient -= OnNewClient; | ||
106 | 100 | ||
101 | enabled = false; | ||
107 | m_SceneList.Clear(); | 102 | m_SceneList.Clear(); |
103 | |||
104 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | ||
108 | } | 105 | } |
106 | m_TransferModule.OnUndeliveredMessage += UndeliveredMessage; | ||
107 | } | ||
108 | } | ||
109 | 109 | ||
110 | m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); | 110 | public void RemoveRegion(Scene scene) |
111 | { | ||
112 | if (!enabled) | ||
111 | return; | 113 | return; |
114 | |||
115 | lock (m_SceneList) | ||
116 | { | ||
117 | m_SceneList.Remove(scene); | ||
112 | } | 118 | } |
119 | } | ||
113 | 120 | ||
114 | trans.OnUndeliveredMessage += UndeliveredMessage; | 121 | public void PostInitialise() |
122 | { | ||
123 | if (!enabled) | ||
124 | return; | ||
115 | 125 | ||
116 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); | 126 | m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); |
117 | } | 127 | } |
@@ -121,9 +131,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
121 | get { return "OfflineMessageModule"; } | 131 | get { return "OfflineMessageModule"; } |
122 | } | 132 | } |
123 | 133 | ||
124 | public bool IsSharedModule | 134 | public Type ReplaceableInterface |
125 | { | 135 | { |
126 | get { return true; } | 136 | get { return null; } |
127 | } | 137 | } |
128 | 138 | ||
129 | public void Close() | 139 | public void Close() |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index f5ab454..267a90a 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs | |||
@@ -24,6 +24,7 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections; | 28 | using System.Collections; |
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Net; | 30 | using System.Net; |
@@ -39,404 +40,54 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 42 | { |
42 | public class PresenceModule : IRegionModule, IPresenceModule | 43 | public class PresenceModule : ISharedRegionModule, IPresenceModule |
43 | { | 44 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger( |
45 | 46 | MethodBase.GetCurrentMethod().DeclaringType); | |
46 | private bool m_Enabled = false; | ||
47 | private bool m_Gridmode = false; | ||
48 | |||
49 | // some default scene for doing things that aren't connected to a specific scene. Avoids locking. | ||
50 | private Scene m_initialScene; | ||
51 | |||
52 | private List<Scene> m_Scenes = new List<Scene>(); | ||
53 | |||
54 | // we currently are only interested in root-agents. If the root isn't here, we don't know the region the | ||
55 | // user is in, so we have to ask the messaging server anyway. | ||
56 | private Dictionary<UUID, Scene> m_RootAgents = | ||
57 | new Dictionary<UUID, Scene>(); | ||
58 | 47 | ||
59 | public event PresenceChange OnPresenceChange; | 48 | public event PresenceChange OnPresenceChange; |
60 | public event BulkPresenceData OnBulkPresenceData; | 49 | public event BulkPresenceData OnBulkPresenceData; |
61 | 50 | ||
62 | public void Initialise(Scene scene, IConfigSource config) | 51 | public void Initialise(IConfigSource config) |
63 | { | 52 | { |
64 | lock (m_Scenes) | ||
65 | { | ||
66 | // This is a shared module; Initialise will be called for every region on this server. | ||
67 | // Only check config once for the first region. | ||
68 | if (m_Scenes.Count == 0) | ||
69 | { | ||
70 | IConfig cnf = config.Configs["Messaging"]; | ||
71 | if (cnf != null && cnf.GetString( | ||
72 | "PresenceModule", "PresenceModule") != | ||
73 | "PresenceModule") | ||
74 | return; | ||
75 | |||
76 | cnf = config.Configs["Startup"]; | ||
77 | if (cnf != null) | ||
78 | m_Gridmode = cnf.GetBoolean("gridmode", false); | ||
79 | |||
80 | m_Enabled = true; | ||
81 | |||
82 | m_initialScene = scene; | ||
83 | } | ||
84 | |||
85 | if (m_Gridmode) | ||
86 | NotifyMessageServerOfStartup(scene); | ||
87 | |||
88 | m_Scenes.Add(scene); | ||
89 | } | ||
90 | |||
91 | scene.RegisterModuleInterface<IPresenceModule>(this); | ||
92 | |||
93 | scene.EventManager.OnNewClient += OnNewClient; | ||
94 | scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; | ||
95 | scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; | ||
96 | } | 53 | } |
97 | 54 | ||
98 | public void PostInitialise() | 55 | public void AddRegion(Scene scene) |
99 | { | 56 | { |
100 | } | 57 | } |
101 | 58 | ||
102 | public void Close() | 59 | public void RegionLoaded(Scene scene) |
103 | { | 60 | { |
104 | if (!m_Gridmode || !m_Enabled) | ||
105 | return; | ||
106 | |||
107 | if (OnPresenceChange != null) | ||
108 | { | ||
109 | lock (m_RootAgents) | ||
110 | { | ||
111 | // on shutdown, users are kicked, too | ||
112 | foreach (KeyValuePair<UUID, Scene> pair in m_RootAgents) | ||
113 | { | ||
114 | OnPresenceChange(new PresenceInfo(pair.Key, UUID.Zero)); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | lock (m_Scenes) | ||
120 | { | ||
121 | foreach (Scene scene in m_Scenes) | ||
122 | NotifyMessageServerOfShutdown(scene); | ||
123 | } | ||
124 | } | 61 | } |
125 | 62 | ||
126 | public string Name | 63 | public void RemoveRegion(Scene scene) |
127 | { | 64 | { |
128 | get { return "PresenceModule"; } | ||
129 | } | ||
130 | |||
131 | public bool IsSharedModule | ||
132 | { | ||
133 | get { return true; } | ||
134 | } | ||
135 | |||
136 | public void RequestBulkPresenceData(UUID[] users) | ||
137 | { | ||
138 | if (OnBulkPresenceData != null) | ||
139 | { | ||
140 | PresenceInfo[] result = new PresenceInfo[users.Length]; | ||
141 | if (m_Gridmode) | ||
142 | { | ||
143 | // first check the local information | ||
144 | List<UUID> uuids = new List<UUID>(); // the uuids to check remotely | ||
145 | List<int> indices = new List<int>(); // just for performance. | ||
146 | lock (m_RootAgents) | ||
147 | { | ||
148 | for (int i = 0; i < uuids.Count; ++i) | ||
149 | { | ||
150 | Scene scene; | ||
151 | if (m_RootAgents.TryGetValue(users[i], out scene)) | ||
152 | { | ||
153 | result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | uuids.Add(users[i]); | ||
158 | indices.Add(i); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | |||
163 | // now we have filtered out all the local root agents. The rest we have to request info about | ||
164 | Dictionary<UUID, FriendRegionInfo> infos = m_initialScene.GetFriendRegionInfos(uuids); | ||
165 | for (int i = 0; i < uuids.Count; ++i) | ||
166 | { | ||
167 | FriendRegionInfo info; | ||
168 | if (infos.TryGetValue(uuids[i], out info) && info.isOnline) | ||
169 | { | ||
170 | UUID regionID = info.regionID; | ||
171 | if (regionID == UUID.Zero) | ||
172 | { | ||
173 | // TODO this is the old messaging-server protocol; only the regionHandle is available. | ||
174 | // Fetch region-info to get the id | ||
175 | uint x = 0, y = 0; | ||
176 | Utils.LongToUInts(info.regionHandle, out x, out y); | ||
177 | GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, | ||
178 | (int)x, (int)y); | ||
179 | regionID = regionInfo.RegionID; | ||
180 | } | ||
181 | result[indices[i]] = new PresenceInfo(uuids[i], regionID); | ||
182 | } | ||
183 | else result[indices[i]] = new PresenceInfo(uuids[i], UUID.Zero); | ||
184 | } | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | // in standalone mode, we have all the info locally available. | ||
189 | lock (m_RootAgents) | ||
190 | { | ||
191 | for (int i = 0; i < users.Length; ++i) | ||
192 | { | ||
193 | Scene scene; | ||
194 | if (m_RootAgents.TryGetValue(users[i], out scene)) | ||
195 | { | ||
196 | result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | result[i] = new PresenceInfo(users[i], UUID.Zero); | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | |||
206 | // tell everyone | ||
207 | OnBulkPresenceData(result); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | // new client doesn't mean necessarily that user logged in, it just means it entered one of the | ||
212 | // the regions on this server | ||
213 | public void OnNewClient(IClientAPI client) | ||
214 | { | ||
215 | client.OnConnectionClosed += OnConnectionClosed; | ||
216 | client.OnLogout += OnLogout; | ||
217 | |||
218 | // KLUDGE: See handler for details. | ||
219 | client.OnEconomyDataRequest += OnEconomyDataRequest; | ||
220 | } | 65 | } |
221 | 66 | ||
222 | // connection closed just means *one* client connection has been closed. It doesn't mean that the | 67 | public void PostInitialise() |
223 | // user has logged off; it might have just TPed away. | ||
224 | public void OnConnectionClosed(IClientAPI client) | ||
225 | { | ||
226 | // TODO: Have to think what we have to do here... | ||
227 | // Should we just remove the root from the list (if scene matches)? | ||
228 | if (!(client.Scene is Scene)) | ||
229 | return; | ||
230 | Scene scene = (Scene)client.Scene; | ||
231 | |||
232 | lock (m_RootAgents) | ||
233 | { | ||
234 | Scene rootScene; | ||
235 | if (!(m_RootAgents.TryGetValue(client.AgentId, out rootScene)) || scene != rootScene) | ||
236 | return; | ||
237 | |||
238 | m_RootAgents.Remove(client.AgentId); | ||
239 | } | ||
240 | |||
241 | // Should it have logged off, we'll do the logout part in OnLogout, even if no root is stored | ||
242 | // anymore. It logged off, after all... | ||
243 | } | ||
244 | |||
245 | // Triggered when the user logs off. | ||
246 | public void OnLogout(IClientAPI client) | ||
247 | { | ||
248 | if (!(client.Scene is Scene)) | ||
249 | return; | ||
250 | Scene scene = (Scene)client.Scene; | ||
251 | |||
252 | // On logout, we really remove the client from rootAgents, even if the scene doesn't match | ||
253 | lock (m_RootAgents) | ||
254 | { | ||
255 | if (m_RootAgents.ContainsKey(client.AgentId)) m_RootAgents.Remove(client.AgentId); | ||
256 | } | ||
257 | |||
258 | // now inform the messaging server and anyone who is interested | ||
259 | NotifyMessageServerOfAgentLeaving(client.AgentId, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); | ||
260 | if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(client.AgentId, UUID.Zero)); | ||
261 | } | ||
262 | |||
263 | public void OnSetRootAgentScene(UUID agentID, Scene scene) | ||
264 | { | ||
265 | // OnSetRootAgentScene can be called from several threads at once (with different agentID). | ||
266 | // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without | ||
267 | // correct locking). | ||
268 | lock (m_RootAgents) | ||
269 | { | ||
270 | Scene rootScene; | ||
271 | if (m_RootAgents.TryGetValue(agentID, out rootScene) && scene == rootScene) | ||
272 | { | ||
273 | return; | ||
274 | } | ||
275 | m_RootAgents[agentID] = scene; | ||
276 | } | ||
277 | |||
278 | // inform messaging server that agent changed the region | ||
279 | Util.FireAndForget( | ||
280 | delegate(object o) | ||
281 | { | ||
282 | NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); | ||
283 | } | ||
284 | ); | ||
285 | } | ||
286 | |||
287 | private void OnEconomyDataRequest(UUID agentID) | ||
288 | { | 68 | { |
289 | // KLUDGE: This is the only way I found to get a message (only) after login was completed and the | ||
290 | // client is connected enough to receive UDP packets. | ||
291 | // This packet seems to be sent only once, just after connection was established to the first | ||
292 | // region after login. | ||
293 | // We use it here to trigger a presence update; the old update-on-login was never be heard by | ||
294 | // the freshly logged in viewer, as it wasn't connected to the region at that time. | ||
295 | // TODO: Feel free to replace this by a better solution if you find one. | ||
296 | |||
297 | // get the agent. This should work every time, as we just got a packet from it | ||
298 | ScenePresence agent = null; | ||
299 | lock (m_Scenes) | ||
300 | { | ||
301 | foreach (Scene scene in m_Scenes) | ||
302 | { | ||
303 | agent = scene.GetScenePresence(agentID); | ||
304 | if (agent != null) break; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | // just to be paranoid... | ||
309 | if (agent == null) | ||
310 | { | ||
311 | m_log.ErrorFormat("[PRESENCE]: Got a packet from agent {0} who can't be found anymore!?", agentID); | ||
312 | return; | ||
313 | } | ||
314 | |||
315 | // we are a bit premature here, but the next packet will switch this child agent to root. | ||
316 | if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(agentID, agent.Scene.RegionInfo.RegionID)); | ||
317 | } | 69 | } |
318 | 70 | ||
319 | public void OnMakeChildAgent(ScenePresence agent) | 71 | public void Close() |
320 | { | 72 | { |
321 | // OnMakeChildAgent can be called from several threads at once (with different agent). | ||
322 | // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without | ||
323 | // correct locking). | ||
324 | lock (m_RootAgents) | ||
325 | { | ||
326 | Scene rootScene; | ||
327 | if (m_RootAgents.TryGetValue(agent.UUID, out rootScene) && agent.Scene == rootScene) | ||
328 | { | ||
329 | m_RootAgents.Remove(agent.UUID); | ||
330 | } | ||
331 | } | ||
332 | // don't notify the messaging-server; either this agent just had been downgraded and another one will be upgraded | ||
333 | // to root momentarily (which will notify the messaging-server), or possibly it will be closed in a moment, | ||
334 | // which will update the messaging-server, too. | ||
335 | } | 73 | } |
336 | 74 | ||
337 | private void NotifyMessageServerOfStartup(Scene scene) | 75 | public string Name |
338 | { | 76 | { |
339 | Hashtable xmlrpcdata = new Hashtable(); | 77 | get { return "PresenceModule"; } |
340 | xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); | ||
341 | ArrayList SendParams = new ArrayList(); | ||
342 | SendParams.Add(xmlrpcdata); | ||
343 | try | ||
344 | { | ||
345 | XmlRpcRequest UpRequest = new XmlRpcRequest("region_startup", SendParams); | ||
346 | XmlRpcResponse resp = UpRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
347 | |||
348 | Hashtable responseData = (Hashtable)resp.Value; | ||
349 | if (responseData == null || (!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
350 | { | ||
351 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); | ||
352 | } | ||
353 | } | ||
354 | catch (WebException) | ||
355 | { | ||
356 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); | ||
357 | } | ||
358 | } | 78 | } |
359 | 79 | ||
360 | private void NotifyMessageServerOfShutdown(Scene scene) | 80 | public Type ReplaceableInterface |
361 | { | 81 | { |
362 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | 82 | get { return null; } |
363 | return; | ||
364 | |||
365 | Hashtable xmlrpcdata = new Hashtable(); | ||
366 | xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); | ||
367 | ArrayList SendParams = new ArrayList(); | ||
368 | SendParams.Add(xmlrpcdata); | ||
369 | try | ||
370 | { | ||
371 | XmlRpcRequest DownRequest = new XmlRpcRequest("region_shutdown", SendParams); | ||
372 | XmlRpcResponse resp = DownRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
373 | |||
374 | Hashtable responseData = (Hashtable)resp.Value; | ||
375 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
376 | { | ||
377 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); | ||
378 | } | ||
379 | } | ||
380 | catch (WebException) | ||
381 | { | ||
382 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); | ||
383 | } | ||
384 | } | 83 | } |
385 | 84 | ||
386 | private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) | 85 | public void RequestBulkPresenceData(UUID[] users) |
387 | { | 86 | { |
388 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | ||
389 | return; | ||
390 | |||
391 | Hashtable xmlrpcdata = new Hashtable(); | ||
392 | xmlrpcdata["AgentID"] = agentID.ToString(); | ||
393 | xmlrpcdata["RegionUUID"] = region.ToString(); | ||
394 | xmlrpcdata["RegionHandle"] = regionHandle.ToString(); | ||
395 | ArrayList SendParams = new ArrayList(); | ||
396 | SendParams.Add(xmlrpcdata); | ||
397 | try | ||
398 | { | ||
399 | XmlRpcRequest LocationRequest = new XmlRpcRequest("agent_location", SendParams); | ||
400 | XmlRpcResponse resp = LocationRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
401 | |||
402 | Hashtable responseData = (Hashtable)resp.Value; | ||
403 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
404 | { | ||
405 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); | ||
406 | } | ||
407 | } | ||
408 | catch (WebException) | ||
409 | { | ||
410 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); | ||
411 | } | ||
412 | } | 87 | } |
413 | 88 | ||
414 | private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) | 89 | public void OnNewClient(IClientAPI client) |
415 | { | 90 | { |
416 | if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) | ||
417 | return; | ||
418 | |||
419 | Hashtable xmlrpcdata = new Hashtable(); | ||
420 | xmlrpcdata["AgentID"] = agentID.ToString(); | ||
421 | xmlrpcdata["RegionUUID"] = region.ToString(); | ||
422 | xmlrpcdata["RegionHandle"] = regionHandle.ToString(); | ||
423 | ArrayList SendParams = new ArrayList(); | ||
424 | SendParams.Add(xmlrpcdata); | ||
425 | try | ||
426 | { | ||
427 | XmlRpcRequest LeavingRequest = new XmlRpcRequest("agent_leaving", SendParams); | ||
428 | XmlRpcResponse resp = LeavingRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); | ||
429 | |||
430 | Hashtable responseData = (Hashtable)resp.Value; | ||
431 | if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") | ||
432 | { | ||
433 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); | ||
434 | } | ||
435 | } | ||
436 | catch (WebException) | ||
437 | { | ||
438 | m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); | ||
439 | } | ||
440 | } | 91 | } |
441 | } | 92 | } |
442 | } | 93 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..55d4f14 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Services.Interfaces; | |||
39 | 39 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | 40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer |
41 | { | 41 | { |
42 | public class InventoryTransferModule : IInventoryTransferModule, IRegionModule | 42 | public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule |
43 | { | 43 | { |
44 | private static readonly ILog m_log | 44 | private static readonly ILog m_log |
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -50,10 +50,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
50 | new Dictionary<UUID, Scene>(); | 50 | new Dictionary<UUID, Scene>(); |
51 | 51 | ||
52 | private IMessageTransferModule m_TransferModule = null; | 52 | private IMessageTransferModule m_TransferModule = null; |
53 | private bool m_Enabled = true; | ||
53 | 54 | ||
54 | #region IRegionModule Members | 55 | #region IRegionModule Members |
55 | 56 | ||
56 | public void Initialise(Scene scene, IConfigSource config) | 57 | public void Initialise(IConfigSource config) |
57 | { | 58 | { |
58 | if (config.Configs["Messaging"] != null) | 59 | if (config.Configs["Messaging"] != null) |
59 | { | 60 | { |
@@ -62,29 +63,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
62 | if (config.Configs["Messaging"].GetString( | 63 | if (config.Configs["Messaging"].GetString( |
63 | "InventoryTransferModule", "InventoryTransferModule") != | 64 | "InventoryTransferModule", "InventoryTransferModule") != |
64 | "InventoryTransferModule") | 65 | "InventoryTransferModule") |
66 | { | ||
67 | m_Enabled = false; | ||
65 | return; | 68 | return; |
69 | } | ||
66 | } | 70 | } |
71 | } | ||
67 | 72 | ||
68 | if (!m_Scenelist.Contains(scene)) | 73 | public void AddRegion(Scene scene) |
69 | { | 74 | { |
70 | m_Scenelist.Add(scene); | 75 | if (!m_Enabled) |
76 | return; | ||
71 | 77 | ||
72 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); | 78 | m_Scenelist.Add(scene); |
73 | 79 | ||
74 | scene.EventManager.OnNewClient += OnNewClient; | 80 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); |
75 | scene.EventManager.OnClientClosed += ClientLoggedOut; | 81 | |
76 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 82 | scene.EventManager.OnNewClient += OnNewClient; |
77 | } | 83 | scene.EventManager.OnClientClosed += ClientLoggedOut; |
84 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
78 | } | 85 | } |
79 | 86 | ||
80 | public void PostInitialise() | 87 | public void RegionLoaded(Scene scene) |
81 | { | 88 | { |
82 | if (m_Scenelist.Count > 0) | 89 | if (m_TransferModule == null) |
83 | { | 90 | { |
84 | m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>(); | 91 | m_TransferModule = m_Scenelist[0].RequestModuleInterface<IMessageTransferModule>(); |
85 | if (m_TransferModule == null) | 92 | if (m_TransferModule == null) |
93 | { | ||
86 | m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); | 94 | m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); |
95 | m_Enabled = false; | ||
96 | |||
97 | m_Scenelist.Clear(); | ||
98 | scene.EventManager.OnNewClient -= OnNewClient; | ||
99 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
100 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
101 | } | ||
87 | } | 102 | } |
103 | |||
104 | } | ||
105 | |||
106 | public void RemoveRegion(Scene scene) | ||
107 | { | ||
108 | scene.EventManager.OnNewClient -= OnNewClient; | ||
109 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
110 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | ||
111 | m_Scenelist.Remove(scene); | ||
112 | } | ||
113 | |||
114 | public void PostInitialise() | ||
115 | { | ||
88 | } | 116 | } |
89 | 117 | ||
90 | public void Close() | 118 | public void Close() |
@@ -96,9 +124,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
96 | get { return "InventoryModule"; } | 124 | get { return "InventoryModule"; } |
97 | } | 125 | } |
98 | 126 | ||
99 | public bool IsSharedModule | 127 | public Type ReplaceableInterface |
100 | { | 128 | { |
101 | get { return true; } | 129 | get { return null; } |
102 | } | 130 | } |
103 | 131 | ||
104 | #endregion | 132 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 261bd6c..d1d7df2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -37,34 +37,72 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 37 | ||
38 | namespace OpenSim.Region.CoreModules.Avatar.Lure | 38 | namespace OpenSim.Region.CoreModules.Avatar.Lure |
39 | { | 39 | { |
40 | public class LureModule : IRegionModule | 40 | public class LureModule : ISharedRegionModule |
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger( |
43 | MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | 44 | ||
44 | private readonly List<Scene> m_scenes = new List<Scene>(); | 45 | private readonly List<Scene> m_scenes = new List<Scene>(); |
45 | 46 | ||
46 | private IMessageTransferModule m_TransferModule = null; | 47 | private IMessageTransferModule m_TransferModule = null; |
48 | private bool m_Enabled = true; | ||
47 | 49 | ||
48 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(IConfigSource config) |
49 | { | 51 | { |
50 | if (config.Configs["Messaging"] != null) | 52 | if (config.Configs["Messaging"] != null) |
51 | { | 53 | { |
52 | if (config.Configs["Messaging"].GetString( | 54 | if (config.Configs["Messaging"].GetString( |
53 | "LureModule", "LureModule") != | 55 | "LureModule", "LureModule") != |
54 | "LureModule") | 56 | "LureModule") |
55 | return; | 57 | m_Enabled = false; |
56 | } | 58 | } |
59 | } | ||
60 | |||
61 | public void AddRegion(Scene scene) | ||
62 | { | ||
63 | if (!m_Enabled) | ||
64 | return; | ||
57 | 65 | ||
58 | lock (m_scenes) | 66 | lock (m_scenes) |
59 | { | 67 | { |
60 | if (!m_scenes.Contains(scene)) | 68 | m_scenes.Add(scene); |
69 | scene.EventManager.OnNewClient += OnNewClient; | ||
70 | scene.EventManager.OnIncomingInstantMessage += | ||
71 | OnGridInstantMessage; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void RegionLoaded(Scene scene) | ||
76 | { | ||
77 | if (m_TransferModule == null) | ||
78 | { | ||
79 | m_TransferModule = | ||
80 | scene.RequestModuleInterface<IMessageTransferModule>(); | ||
81 | |||
82 | if (m_TransferModule == null) | ||
61 | { | 83 | { |
62 | m_scenes.Add(scene); | 84 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ |
63 | scene.EventManager.OnNewClient += OnNewClient; | 85 | "lures will not work!"); |
64 | scene.EventManager.OnIncomingInstantMessage += | 86 | |
87 | m_Enabled = false; | ||
88 | m_scenes.Clear(); | ||
89 | scene.EventManager.OnNewClient -= OnNewClient; | ||
90 | scene.EventManager.OnIncomingInstantMessage -= | ||
65 | OnGridInstantMessage; | 91 | OnGridInstantMessage; |
66 | } | 92 | } |
67 | } | 93 | } |
94 | |||
95 | } | ||
96 | |||
97 | public void RemoveRegion(Scene scene) | ||
98 | { | ||
99 | lock (m_scenes) | ||
100 | { | ||
101 | m_scenes.Remove(scene); | ||
102 | scene.EventManager.OnNewClient -= OnNewClient; | ||
103 | scene.EventManager.OnIncomingInstantMessage -= | ||
104 | OnGridInstantMessage; | ||
105 | } | ||
68 | } | 106 | } |
69 | 107 | ||
70 | void OnNewClient(IClientAPI client) | 108 | void OnNewClient(IClientAPI client) |
@@ -76,12 +114,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
76 | 114 | ||
77 | public void PostInitialise() | 115 | public void PostInitialise() |
78 | { | 116 | { |
79 | m_TransferModule = | ||
80 | m_scenes[0].RequestModuleInterface<IMessageTransferModule>(); | ||
81 | |||
82 | if (m_TransferModule == null) | ||
83 | m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ | ||
84 | "lures will not work!"); | ||
85 | } | 117 | } |
86 | 118 | ||
87 | public void Close() | 119 | public void Close() |
@@ -93,9 +125,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
93 | get { return "LureModule"; } | 125 | get { return "LureModule"; } |
94 | } | 126 | } |
95 | 127 | ||
96 | public bool IsSharedModule | 128 | public Type ReplaceableInterface |
97 | { | 129 | { |
98 | get { return true; } | 130 | get { return null; } |
99 | } | 131 | } |
100 | 132 | ||
101 | public void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 133 | public void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index beb2307..e4b0fd5 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -17,13 +17,19 @@ | |||
17 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> | 17 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> |
18 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> | 18 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> |
19 | <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> | 19 | <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> |
20 | <RegionModule id="FriendsModule" type="OpenSim.Region.CoreModules.Avatar.Friends.FriendsModule" /> | ||
21 | <RegionModule id="PresenceModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.PresenceModule" /> | ||
22 | <RegionModule id="MuteListModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MuteListModule" /> | ||
23 | <RegionModule id="OfflineMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.OfflineMessageModule" /> | ||
24 | <RegionModule id="InstantMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.InstantMessageModule" /> | ||
25 | <RegionModule id="MessageTransferModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MessageTransferModule" /> | ||
26 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> | ||
27 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> | ||
20 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> | 28 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> |
21 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> | 29 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> |
22 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> | 30 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> |
23 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> | 31 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> |
24 | <!-- Service connectors OUT modules --> | 32 | <!-- Service connectors OUT modules --> |
25 | <RegionModule id="LocalUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.LocalUserServicesConnector" /> | ||
26 | <RegionModule id="RemoteUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.User.RemoteUserServicesConnector" /> | ||
27 | <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> | 33 | <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> |
28 | <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> | 34 | <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> |
29 | <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> | 35 | <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> |
@@ -41,6 +47,10 @@ | |||
41 | <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> | 47 | <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> |
42 | <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> | 48 | <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> |
43 | <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" /> | 49 | <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" /> |
50 | <RegionModule id="LocalPresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.LocalPresenceServicesConnector" /> | ||
51 | <RegionModule id="RemotePresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.RemotePresenceServicesConnector" /> | ||
52 | <RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" /> | ||
53 | <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" /> | ||
44 | <!-- Service connectors IN modules --> | 54 | <!-- Service connectors IN modules --> |
45 | <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> | 55 | <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> |
46 | <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> | 56 | <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 44458d1..fa3681a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs | |||
@@ -436,12 +436,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
436 | } | 436 | } |
437 | 437 | ||
438 | OSDMap resp = new OSDMap(2); | 438 | OSDMap resp = new OSDMap(2); |
439 | string reason = String.Empty; | 439 | string reason = String.Empty; |
440 | uint teleportFlags = 0; | 440 | uint teleportFlags = 0; |
441 | if (args.ContainsKey("teleport_flags")) | 441 | if (args.ContainsKey("teleport_flags")) |
442 | { | 442 | { |
443 | teleportFlags = args["teleport_flags"].AsUInteger(); | 443 | teleportFlags = args["teleport_flags"].AsUInteger(); |
444 | } | 444 | } |
445 | 445 | ||
446 | // This is the meaning of POST agent | 446 | // This is the meaning of POST agent |
447 | m_regionClient.AdjustUserInformation(aCircuit); | 447 | m_regionClient.AdjustUserInformation(aCircuit); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs new file mode 100644 index 0000000..2cb18c7 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | |||
@@ -0,0 +1,200 @@ | |||
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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
36 | |||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | using Nini.Config; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
42 | { | ||
43 | public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private bool m_Enabled = false; | ||
48 | |||
49 | private PresenceDetector m_PresenceDetector; | ||
50 | private IPresenceService m_PresenceService; | ||
51 | |||
52 | public LocalPresenceServicesConnector() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public LocalPresenceServicesConnector(IConfigSource source) | ||
57 | { | ||
58 | Initialise(source); | ||
59 | } | ||
60 | |||
61 | #region ISharedRegionModule | ||
62 | |||
63 | public Type ReplaceableInterface | ||
64 | { | ||
65 | get { return null; } | ||
66 | } | ||
67 | |||
68 | public string Name | ||
69 | { | ||
70 | get { return "LocalPresenceServicesConnector"; } | ||
71 | } | ||
72 | |||
73 | public void Initialise(IConfigSource source) | ||
74 | { | ||
75 | IConfig moduleConfig = source.Configs["Modules"]; | ||
76 | if (moduleConfig != null) | ||
77 | { | ||
78 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
79 | if (name == Name) | ||
80 | { | ||
81 | IConfig inventoryConfig = source.Configs["PresenceService"]; | ||
82 | if (inventoryConfig == null) | ||
83 | { | ||
84 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty); | ||
89 | |||
90 | if (serviceDll == String.Empty) | ||
91 | { | ||
92 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section PresenceService"); | ||
93 | return; | ||
94 | } | ||
95 | |||
96 | Object[] args = new Object[] { source }; | ||
97 | m_log.DebugFormat("[LOCAL PRESENCE CONNECTOR]: Service dll = {0}", serviceDll); | ||
98 | |||
99 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(serviceDll, args); | ||
100 | |||
101 | if (m_PresenceService == null) | ||
102 | { | ||
103 | m_log.Error("[LOCAL PRESENCE CONNECTOR]: Can't load presence service"); | ||
104 | //return; | ||
105 | throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); | ||
106 | } | ||
107 | |||
108 | //Init(source); | ||
109 | |||
110 | m_PresenceDetector = new PresenceDetector(this); | ||
111 | |||
112 | m_Enabled = true; | ||
113 | m_log.Info("[LOCAL PRESENCE CONNECTOR]: Local presence connector enabled"); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public void PostInitialise() | ||
119 | { | ||
120 | } | ||
121 | |||
122 | public void Close() | ||
123 | { | ||
124 | } | ||
125 | |||
126 | public void AddRegion(Scene scene) | ||
127 | { | ||
128 | if (!m_Enabled) | ||
129 | return; | ||
130 | |||
131 | // m_log.DebugFormat( | ||
132 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
133 | |||
134 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
135 | m_PresenceDetector.AddRegion(scene); | ||
136 | |||
137 | m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); | ||
138 | |||
139 | } | ||
140 | |||
141 | public void RemoveRegion(Scene scene) | ||
142 | { | ||
143 | if (!m_Enabled) | ||
144 | return; | ||
145 | |||
146 | m_PresenceDetector.RemoveRegion(scene); | ||
147 | } | ||
148 | |||
149 | public void RegionLoaded(Scene scene) | ||
150 | { | ||
151 | if (!m_Enabled) | ||
152 | return; | ||
153 | |||
154 | } | ||
155 | |||
156 | #endregion | ||
157 | |||
158 | #region IPresenceService | ||
159 | |||
160 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
161 | { | ||
162 | m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
163 | return false; | ||
164 | } | ||
165 | |||
166 | public bool LogoutAgent(UUID sessionID) | ||
167 | { | ||
168 | return m_PresenceService.LogoutAgent(sessionID); | ||
169 | } | ||
170 | |||
171 | |||
172 | public bool LogoutRegionAgents(UUID regionID) | ||
173 | { | ||
174 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
175 | } | ||
176 | |||
177 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
178 | { | ||
179 | return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt); | ||
180 | } | ||
181 | |||
182 | public PresenceInfo GetAgent(UUID sessionID) | ||
183 | { | ||
184 | return m_PresenceService.GetAgent(sessionID); | ||
185 | } | ||
186 | |||
187 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
188 | { | ||
189 | return m_PresenceService.GetAgents(userIDs); | ||
190 | } | ||
191 | |||
192 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
193 | { | ||
194 | return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt); | ||
195 | } | ||
196 | |||
197 | #endregion | ||
198 | |||
199 | } | ||
200 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs new file mode 100644 index 0000000..3ca5560 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | |||
@@ -0,0 +1,84 @@ | |||
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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using log4net; | ||
37 | |||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
39 | { | ||
40 | public class PresenceDetector | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private IPresenceService m_PresenceService; | ||
45 | |||
46 | public PresenceDetector(IPresenceService presenceservice) | ||
47 | { | ||
48 | m_PresenceService = presenceservice; | ||
49 | } | ||
50 | |||
51 | public void AddRegion(Scene scene) | ||
52 | { | ||
53 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | ||
54 | scene.EventManager.OnNewClient += OnNewClient; | ||
55 | |||
56 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
57 | } | ||
58 | |||
59 | public void RemoveRegion(Scene scene) | ||
60 | { | ||
61 | scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent; | ||
62 | scene.EventManager.OnNewClient -= OnNewClient; | ||
63 | |||
64 | m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); | ||
65 | } | ||
66 | |||
67 | public void OnMakeRootAgent(ScenePresence sp) | ||
68 | { | ||
69 | m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); | ||
70 | m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | ||
71 | } | ||
72 | |||
73 | public void OnNewClient(IClientAPI client) | ||
74 | { | ||
75 | client.OnLogout += OnLogout; | ||
76 | } | ||
77 | |||
78 | public void OnLogout(IClientAPI client) | ||
79 | { | ||
80 | client.OnLogout -= OnLogout; | ||
81 | m_PresenceService.LogoutAgent(client.SessionId); | ||
82 | } | ||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs new file mode 100644 index 0000000..e8e140a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | |||
@@ -0,0 +1,164 @@ | |||
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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | |||
31 | using OpenSim.Region.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Server.Base; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | using OpenSim.Services.Connectors; | ||
36 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
37 | |||
38 | using OpenMetaverse; | ||
39 | using log4net; | ||
40 | using Nini.Config; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
43 | { | ||
44 | public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | #region ISharedRegionModule | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | private PresenceDetector m_PresenceDetector; | ||
53 | private IPresenceService m_RemoteConnector; | ||
54 | |||
55 | public Type ReplaceableInterface | ||
56 | { | ||
57 | get { return null; } | ||
58 | } | ||
59 | |||
60 | public string Name | ||
61 | { | ||
62 | get { return "RemotePresenceServiceConnector"; } | ||
63 | } | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig moduleConfig = source.Configs["Modules"]; | ||
68 | if (moduleConfig != null) | ||
69 | { | ||
70 | string name = moduleConfig.GetString("PresenceServices", ""); | ||
71 | if (name == Name) | ||
72 | { | ||
73 | m_RemoteConnector = new PresenceServicesConnector(source); | ||
74 | |||
75 | m_Enabled = true; | ||
76 | |||
77 | m_PresenceDetector = new PresenceDetector(this); | ||
78 | |||
79 | m_log.Info("[INVENTORY CONNECTOR]: Remote presence enabled"); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | } | ||
84 | |||
85 | public void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
99 | m_PresenceDetector.AddRegion(scene); | ||
100 | |||
101 | m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); | ||
102 | |||
103 | } | ||
104 | |||
105 | public void RemoveRegion(Scene scene) | ||
106 | { | ||
107 | if (!m_Enabled) | ||
108 | return; | ||
109 | |||
110 | m_PresenceDetector.RemoveRegion(scene); | ||
111 | } | ||
112 | |||
113 | public void RegionLoaded(Scene scene) | ||
114 | { | ||
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | } | ||
119 | |||
120 | #endregion | ||
121 | |||
122 | #region IPresenceService | ||
123 | |||
124 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
125 | { | ||
126 | m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | public bool LogoutAgent(UUID sessionID) | ||
131 | { | ||
132 | return m_RemoteConnector.LogoutAgent(sessionID); | ||
133 | } | ||
134 | |||
135 | |||
136 | public bool LogoutRegionAgents(UUID regionID) | ||
137 | { | ||
138 | return m_RemoteConnector.LogoutRegionAgents(regionID); | ||
139 | } | ||
140 | |||
141 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
142 | { | ||
143 | return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt); | ||
144 | } | ||
145 | |||
146 | public PresenceInfo GetAgent(UUID sessionID) | ||
147 | { | ||
148 | return m_RemoteConnector.GetAgent(sessionID); | ||
149 | } | ||
150 | |||
151 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
152 | { | ||
153 | return m_RemoteConnector.GetAgents(userIDs); | ||
154 | } | ||
155 | |||
156 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
157 | { | ||
158 | return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt); | ||
159 | } | ||
160 | |||
161 | #endregion | ||
162 | |||
163 | } | ||
164 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs new file mode 100644 index 0000000..ebb2c3e --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -0,0 +1,104 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using Nini.Config; | ||
39 | |||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Setup; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | ||
47 | { | ||
48 | [TestFixture] | ||
49 | public class PresenceConnectorsTests | ||
50 | { | ||
51 | LocalPresenceServicesConnector m_LocalConnector; | ||
52 | private void SetUp() | ||
53 | { | ||
54 | IConfigSource config = new IniConfigSource(); | ||
55 | config.AddConfig("Modules"); | ||
56 | config.AddConfig("PresenceService"); | ||
57 | config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); | ||
58 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | ||
59 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData"); | ||
60 | |||
61 | m_LocalConnector = new LocalPresenceServicesConnector(config); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Test OpenSim Presence. | ||
66 | /// </summary> | ||
67 | [Test] | ||
68 | public void TestPresenceV0_1() | ||
69 | { | ||
70 | SetUp(); | ||
71 | |||
72 | string user1 = UUID.Zero.ToString(); | ||
73 | UUID session1 = UUID.Zero; | ||
74 | |||
75 | // this is not implemented by this connector | ||
76 | //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero); | ||
77 | PresenceInfo result = m_LocalConnector.GetAgent(session1); | ||
78 | Assert.IsNotNull(result, "Retrieved GetAgent is null"); | ||
79 | Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match"); | ||
80 | Assert.IsTrue(result.Online, "Agent just logged in but is offline"); | ||
81 | |||
82 | UUID region1 = UUID.Random(); | ||
83 | bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
84 | Assert.IsTrue(r, "First ReportAgent returned false"); | ||
85 | result = m_LocalConnector.GetAgent(session1); | ||
86 | Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)"); | ||
87 | |||
88 | UUID region2 = UUID.Random(); | ||
89 | r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero); | ||
90 | Assert.IsTrue(r, "Second ReportAgent returned false"); | ||
91 | result = m_LocalConnector.GetAgent(session1); | ||
92 | Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)"); | ||
93 | |||
94 | r = m_LocalConnector.LogoutAgent(session1); | ||
95 | Assert.IsTrue(r, "LogoutAgent returned false"); | ||
96 | result = m_LocalConnector.GetAgent(session1); | ||
97 | Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); | ||
98 | Assert.IsFalse(result.Online, "Agent is reported to be Online after logout"); | ||
99 | |||
100 | r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); | ||
101 | Assert.IsFalse(r, "ReportAgent of non-logged in user returned true"); | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index cca5bb4..f55de5a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
@@ -34,9 +35,11 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Server.Base; | 35 | using OpenSim.Server.Base; |
35 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 38 | using OpenMetaverse; |
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | ||
38 | { | 41 | { |
39 | public class LocalUserServicesConnector : ISharedRegionModule | 42 | public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService |
40 | { | 43 | { |
41 | private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
42 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
@@ -46,6 +49,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
46 | 49 | ||
47 | private bool m_Enabled = false; | 50 | private bool m_Enabled = false; |
48 | 51 | ||
52 | #region ISharedRegionModule | ||
53 | |||
49 | public Type ReplaceableInterface | 54 | public Type ReplaceableInterface |
50 | { | 55 | { |
51 | get { return null; } | 56 | get { return null; } |
@@ -53,7 +58,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
53 | 58 | ||
54 | public string Name | 59 | public string Name |
55 | { | 60 | { |
56 | get { return "LocalUserServicesConnector"; } | 61 | get { return "LocalUserAccountServicesConnector"; } |
57 | } | 62 | } |
58 | 63 | ||
59 | public void Initialise(IConfigSource source) | 64 | public void Initialise(IConfigSource source) |
@@ -61,13 +66,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
61 | IConfig moduleConfig = source.Configs["Modules"]; | 66 | IConfig moduleConfig = source.Configs["Modules"]; |
62 | if (moduleConfig != null) | 67 | if (moduleConfig != null) |
63 | { | 68 | { |
64 | string name = moduleConfig.GetString("UserServices", ""); | 69 | string name = moduleConfig.GetString("UserAccountServices", ""); |
65 | if (name == Name) | 70 | if (name == Name) |
66 | { | 71 | { |
67 | IConfig userConfig = source.Configs["UserService"]; | 72 | IConfig userConfig = source.Configs["UserAccountService"]; |
68 | if (userConfig == null) | 73 | if (userConfig == null) |
69 | { | 74 | { |
70 | m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); | 75 | m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini"); |
71 | return; | 76 | return; |
72 | } | 77 | } |
73 | 78 | ||
@@ -87,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
87 | 92 | ||
88 | if (m_UserService == null) | 93 | if (m_UserService == null) |
89 | { | 94 | { |
90 | m_log.Error("[USER CONNECTOR]: Can't load user service"); | 95 | m_log.Error("[USER CONNECTOR]: Can't load user account service"); |
91 | return; | 96 | return; |
92 | } | 97 | } |
93 | m_Enabled = true; | 98 | m_Enabled = true; |
@@ -127,5 +132,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
127 | if (!m_Enabled) | 132 | if (!m_Enabled) |
128 | return; | 133 | return; |
129 | } | 134 | } |
135 | |||
136 | #endregion | ||
137 | |||
138 | #region IUserAccountService | ||
139 | |||
140 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
141 | { | ||
142 | return m_UserService.GetUserAccount(scopeID, userID); | ||
143 | } | ||
144 | |||
145 | public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) | ||
146 | { | ||
147 | return m_UserService.GetUserAccount(scopeID, FirstName, LastName); | ||
148 | } | ||
149 | |||
150 | public UserAccount GetUserAccount(UUID scopeID, string Email) | ||
151 | { | ||
152 | return m_UserService.GetUserAccount(scopeID, Email); | ||
153 | } | ||
154 | |||
155 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
156 | { | ||
157 | return m_UserService.GetUserAccounts(scopeID, query); | ||
158 | } | ||
159 | |||
160 | // Update all updatable fields | ||
161 | // | ||
162 | public bool StoreUserAccount(UserAccount data) | ||
163 | { | ||
164 | return m_UserService.StoreUserAccount(data); | ||
165 | } | ||
166 | |||
167 | #endregion | ||
168 | |||
130 | } | 169 | } |
131 | } | 170 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index cef9129..d322aba 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -34,9 +34,9 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
35 | using OpenSim.Services.Connectors; | 35 | using OpenSim.Services.Connectors; |
36 | 36 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | 37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
38 | { | 38 | { |
39 | public class RemoteUserServicesConnector : UserServicesConnector, | 39 | public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, |
40 | ISharedRegionModule, IUserAccountService | 40 | ISharedRegionModule, IUserAccountService |
41 | { | 41 | { |
42 | private static readonly ILog m_log = | 42 | private static readonly ILog m_log = |
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User | |||
52 | 52 | ||
53 | public string Name | 53 | public string Name |
54 | { | 54 | { |
55 | get { return "RemoteUserServicesConnector"; } | 55 | get { return "RemoteUserAccountServicesConnector"; } |
56 | } | 56 | } |
57 | 57 | ||
58 | public override void Initialise(IConfigSource source) | 58 | public override void Initialise(IConfigSource source) |
diff --git a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs index 630c6a3..d44c1e1 100644 --- a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs | |||
@@ -31,13 +31,13 @@ namespace OpenSim.Region.Framework.Interfaces | |||
31 | { | 31 | { |
32 | public struct PresenceInfo | 32 | public struct PresenceInfo |
33 | { | 33 | { |
34 | public UUID userID; | 34 | public string UserID; |
35 | public UUID regionID; | 35 | public UUID RegionID; |
36 | 36 | ||
37 | public PresenceInfo(UUID userID, UUID regionID) | 37 | public PresenceInfo(string userID, UUID regionID) |
38 | { | 38 | { |
39 | this.userID = userID; | 39 | UserID = userID; |
40 | this.regionID = regionID; | 40 | RegionID = regionID; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0e1e2be..7db99e1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4889,5 +4889,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4889 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4889 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) |
4890 | StartTimer(); | 4890 | StartTimer(); |
4891 | } | 4891 | } |
4892 | |||
4893 | public override ISceneObject DeserializeObject(string representation) | ||
4894 | { | ||
4895 | return SceneObjectSerializer.FromXml2Format(representation); | ||
4896 | } | ||
4897 | |||
4898 | public override bool AllowScriptCrossings | ||
4899 | { | ||
4900 | get { return m_allowScriptCrossings; } | ||
4901 | } | ||
4892 | } | 4902 | } |
4893 | } | 4903 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 1547f9a..19eea1e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -510,5 +510,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
510 | 510 | ||
511 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); | 511 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); |
512 | } | 512 | } |
513 | |||
514 | public virtual ISceneObject DeserializeObject(string representation) | ||
515 | { | ||
516 | return null; | ||
517 | } | ||
518 | |||
519 | public virtual bool AllowScriptCrossings | ||
520 | { | ||
521 | get { return false; } | ||
522 | } | ||
523 | |||
513 | } | 524 | } |
514 | } | 525 | } |