diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/Null/NullAvatarData.cs (renamed from OpenSim/Grid/MessagingServer.Modules/PresenceBackreferenceEntry.cs) | 77 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullFriendsData.cs (renamed from OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs) | 73 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs | 187 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs | 200 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/MessageService.cs | 503 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/PresenceInformer.cs | 135 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/PresenceService.cs | 33 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/WorkUnitBase.cs | 33 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer.Modules/WorkUnitPresenceUpdate.cs | 33 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs (renamed from OpenSim/Grid/MessagingServer.Modules/UserPresenceData.cs) | 29 |
10 files changed, 99 insertions, 1204 deletions
diff --git a/OpenSim/Grid/MessagingServer.Modules/PresenceBackreferenceEntry.cs b/OpenSim/Data/Null/NullAvatarData.cs index 67dde6d..c81ba43 100644 --- a/OpenSim/Grid/MessagingServer.Modules/PresenceBackreferenceEntry.cs +++ b/OpenSim/Data/Null/NullAvatarData.cs | |||
@@ -25,72 +25,69 @@ | |||
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 | 27 | ||
28 | using System; | ||
29 | using System.Collections; | ||
28 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Data; | ||
30 | 34 | ||
31 | namespace OpenSim.Grid.MessagingServer.Modules | 35 | namespace OpenSim.Data.Null |
32 | { | 36 | { |
33 | // This is a wrapper for a List<UUID> so it can be happily stored in a hashtable. | 37 | public class NullAvatarData : IAvatarData |
34 | public class PresenceBackreferenceEntry | ||
35 | { | 38 | { |
36 | List<UUID> AgentList = new List<UUID>(); | 39 | private static Dictionary<UUID, AvatarBaseData> m_DataByUUID = new Dictionary<UUID, AvatarBaseData>(); |
37 | 40 | ||
38 | public PresenceBackreferenceEntry() | 41 | public NullAvatarData(string connectionString, string realm) |
39 | { | 42 | { |
40 | |||
41 | } | 43 | } |
42 | 44 | ||
43 | public void Add(UUID item) | 45 | public AvatarBaseData[] Get(string field, string val) |
44 | { | 46 | { |
45 | lock (AgentList) | 47 | if (field == "PrincipalID") |
46 | { | 48 | { |
47 | AgentList.Add(item); | 49 | UUID id = UUID.Zero; |
50 | if (UUID.TryParse(val, out id)) | ||
51 | if (m_DataByUUID.ContainsKey(id)) | ||
52 | return new AvatarBaseData[] { m_DataByUUID[id] }; | ||
48 | } | 53 | } |
49 | } | ||
50 | 54 | ||
51 | public UUID getitem(int index) | 55 | // Fail |
52 | { | 56 | return new AvatarBaseData[0]; |
53 | UUID result = UUID.Zero; | ||
54 | lock (AgentList) | ||
55 | { | ||
56 | if (index > 0 && index < AgentList.Count) | ||
57 | { | ||
58 | result = AgentList[index]; | ||
59 | } | ||
60 | } | ||
61 | return result; | ||
62 | } | 57 | } |
63 | 58 | ||
64 | public int Count | 59 | public bool Store(AvatarBaseData data) |
65 | { | 60 | { |
66 | get | 61 | m_DataByUUID[data.PrincipalID] = data; |
67 | { | 62 | return true; |
68 | int count = 0; | ||
69 | lock (AgentList) | ||
70 | { | ||
71 | count = AgentList.Count; | ||
72 | } | ||
73 | return count; | ||
74 | } | ||
75 | } | 63 | } |
76 | 64 | ||
77 | public void Remove(UUID item) | 65 | public bool Delete(UUID principalID, string name) |
78 | { | 66 | { |
79 | lock (AgentList) | 67 | if (m_DataByUUID.ContainsKey(principalID) && m_DataByUUID[principalID].Data.ContainsKey(name)) |
80 | { | 68 | { |
81 | if (AgentList.Contains(item)) | 69 | m_DataByUUID[principalID].Data.Remove(name); |
82 | AgentList.Remove(item); | 70 | return true; |
83 | } | 71 | } |
72 | |||
73 | return false; | ||
84 | } | 74 | } |
85 | 75 | ||
86 | public bool contains(UUID item) | 76 | public bool Delete(string field, string val) |
87 | { | 77 | { |
88 | bool result = false; | 78 | if (field == "PrincipalID") |
89 | lock (AgentList) | ||
90 | { | 79 | { |
91 | result = AgentList.Contains(item); | 80 | UUID id = UUID.Zero; |
81 | if (UUID.TryParse(val, out id)) | ||
82 | if (m_DataByUUID.ContainsKey(id)) | ||
83 | { | ||
84 | m_DataByUUID.Remove(id); | ||
85 | return true; | ||
86 | } | ||
92 | } | 87 | } |
93 | return result; | 88 | |
89 | return false; | ||
94 | } | 90 | } |
91 | |||
95 | } | 92 | } |
96 | } | 93 | } |
diff --git a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs b/OpenSim/Data/Null/NullFriendsData.cs index 76c4899..e7f7fd3 100644 --- a/OpenSim/Grid/MessagingServer.Modules/UserDataBaseService.cs +++ b/OpenSim/Data/Null/NullFriendsData.cs | |||
@@ -25,51 +25,68 @@ | |||
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 | 27 | ||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 31 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
30 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Data; |
31 | 34 | ||
32 | namespace OpenSim.Grid.MessagingServer.Modules | 35 | namespace OpenSim.Data.Null |
33 | { | 36 | { |
34 | public class UserDataBaseService : UserManagerBase | 37 | public class NullFriendsData : IFriendsData |
35 | { | 38 | { |
36 | /// <summary> | 39 | private static List<FriendsData> m_Data = new List<FriendsData>(); |
37 | /// Constructor. | 40 | |
38 | /// </summary> | 41 | public NullFriendsData(string connectionString, string realm) |
39 | /// Passing null to parent because we never use any function that requires an interservice inventory call. | ||
40 | public UserDataBaseService() | ||
41 | : base(null) | ||
42 | { | 42 | { |
43 | } | 43 | } |
44 | |||
45 | public UserAgentData GetUserAgentData(UUID AgentID) | ||
46 | { | ||
47 | UserProfileData userProfile = GetUserProfile(AgentID); | ||
48 | 44 | ||
49 | if (userProfile != null) | 45 | /// <summary> |
46 | /// Tries to implement the Get [] semantics, but it cuts corners. | ||
47 | /// Specifically, it gets all friendships even if they weren't accepted yet. | ||
48 | /// </summary> | ||
49 | /// <param name="fields"></param> | ||
50 | /// <param name="values"></param> | ||
51 | /// <returns></returns> | ||
52 | public FriendsData[] GetFriends(UUID userID) | ||
53 | { | ||
54 | List<FriendsData> lst = m_Data.FindAll(delegate (FriendsData fdata) | ||
50 | { | 55 | { |
51 | return userProfile.CurrentAgent; | 56 | return fdata.PrincipalID == userID; |
52 | } | 57 | }); |
53 | 58 | ||
54 | return null; | 59 | if (lst != null) |
55 | } | 60 | return lst.ToArray(); |
56 | 61 | ||
57 | public override UserProfileData SetupMasterUser(string firstName, string lastName) | 62 | return new FriendsData[0]; |
58 | { | ||
59 | //throw new Exception("The method or operation is not implemented."); | ||
60 | return null; | ||
61 | } | 63 | } |
62 | 64 | ||
63 | public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) | 65 | public bool Store(FriendsData data) |
64 | { | 66 | { |
65 | //throw new Exception("The method or operation is not implemented."); | 67 | if (data == null) |
66 | return null; | 68 | return false; |
69 | |||
70 | m_Data.Add(data); | ||
71 | |||
72 | return true; | ||
67 | } | 73 | } |
68 | 74 | ||
69 | public override UserProfileData SetupMasterUser(UUID uuid) | 75 | public bool Delete(UUID userID, string friendID) |
70 | { | 76 | { |
71 | //throw new Exception("The method or operation is not implemented."); | 77 | List<FriendsData> lst = m_Data.FindAll(delegate(FriendsData fdata) { return fdata.PrincipalID == userID; }); |
72 | return null; | 78 | if (lst != null) |
79 | { | ||
80 | FriendsData friend = lst.Find(delegate(FriendsData fdata) { return fdata.Friend == friendID; }); | ||
81 | if (friendID != null) | ||
82 | { | ||
83 | m_Data.Remove(friend); | ||
84 | return true; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | return false; | ||
73 | } | 89 | } |
90 | |||
74 | } | 91 | } |
75 | } | 92 | } |
diff --git a/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs b/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs deleted file mode 100644 index ae04535..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/InterMessageUserServerModule.cs +++ /dev/null | |||
@@ -1,187 +0,0 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Threading; | ||
34 | using System.Timers; | ||
35 | using log4net; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Data; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | using Timer = System.Timers.Timer; | ||
42 | |||
43 | namespace OpenSim.Grid.MessagingServer.Modules | ||
44 | { | ||
45 | public class InterMessageUserServerModule : IInterServiceUserService | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private MessageServerConfig m_cfg; | ||
50 | |||
51 | private IGridServiceCore m_messageCore; | ||
52 | |||
53 | private Timer reconnectTimer = new Timer(300000); // 5 mins | ||
54 | |||
55 | public InterMessageUserServerModule(MessageServerConfig config, IGridServiceCore messageCore) | ||
56 | { | ||
57 | m_cfg = config; | ||
58 | m_messageCore = messageCore; | ||
59 | |||
60 | reconnectTimer.Elapsed += registerWithUserServer; | ||
61 | lock (reconnectTimer) | ||
62 | reconnectTimer.Start(); | ||
63 | } | ||
64 | |||
65 | public void Initialise() | ||
66 | { | ||
67 | m_messageCore.RegisterInterface<IInterServiceUserService>(this); | ||
68 | } | ||
69 | |||
70 | public void PostInitialise() | ||
71 | { | ||
72 | |||
73 | } | ||
74 | |||
75 | public void RegisterHandlers() | ||
76 | { | ||
77 | //have these in separate method as some servers restart the http server and reregister all the handlers. | ||
78 | |||
79 | } | ||
80 | |||
81 | public void registerWithUserServer(object sender, ElapsedEventArgs e) | ||
82 | { | ||
83 | registerWithUserServer(); | ||
84 | } | ||
85 | |||
86 | public bool registerWithUserServer() | ||
87 | { | ||
88 | Hashtable UserParams = new Hashtable(); | ||
89 | // Login / Authentication | ||
90 | |||
91 | if (m_cfg.HttpSSL) | ||
92 | { | ||
93 | UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
94 | } | ||
95 | else | ||
96 | { | ||
97 | UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
98 | } | ||
99 | |||
100 | UserParams["recvkey"] = m_cfg.UserRecvKey; | ||
101 | UserParams["sendkey"] = m_cfg.UserRecvKey; | ||
102 | |||
103 | // Package into an XMLRPC Request | ||
104 | ArrayList SendParams = new ArrayList(); | ||
105 | SendParams.Add(UserParams); | ||
106 | |||
107 | bool success = true; | ||
108 | string[] servers = m_cfg.UserServerURL.Split(' '); | ||
109 | |||
110 | foreach (string srv in servers) | ||
111 | { | ||
112 | // Send Request | ||
113 | try | ||
114 | { | ||
115 | XmlRpcRequest UserReq = new XmlRpcRequest("register_messageserver", SendParams); | ||
116 | XmlRpcResponse UserResp = UserReq.Send(srv, 16000); | ||
117 | |||
118 | // Process Response | ||
119 | Hashtable GridRespData = (Hashtable)UserResp.Value; | ||
120 | // if we got a response, we were successful | ||
121 | if (!GridRespData.ContainsKey("responsestring")) | ||
122 | success = false; | ||
123 | else | ||
124 | m_log.InfoFormat("[SERVER] Registered with {0}", srv); | ||
125 | } | ||
126 | catch | ||
127 | { | ||
128 | m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv); | ||
129 | success = false; | ||
130 | } | ||
131 | } | ||
132 | return success; | ||
133 | } | ||
134 | |||
135 | public bool deregisterWithUserServer() | ||
136 | { | ||
137 | Hashtable request = new Hashtable(); | ||
138 | |||
139 | return SendToUserServer(request, "deregister_messageserver"); | ||
140 | } | ||
141 | |||
142 | public bool SendToUserServer(Hashtable request, string method) | ||
143 | { | ||
144 | // Login / Authentication | ||
145 | |||
146 | if (m_cfg.HttpSSL) | ||
147 | { | ||
148 | request["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | request["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; | ||
153 | } | ||
154 | |||
155 | request["recvkey"] = m_cfg.UserRecvKey; | ||
156 | request["sendkey"] = m_cfg.UserRecvKey; | ||
157 | |||
158 | // Package into an XMLRPC Request | ||
159 | ArrayList SendParams = new ArrayList(); | ||
160 | SendParams.Add(request); | ||
161 | |||
162 | bool success = true; | ||
163 | string[] servers = m_cfg.UserServerURL.Split(' '); | ||
164 | |||
165 | // Send Request | ||
166 | foreach (string srv in servers) | ||
167 | { | ||
168 | try | ||
169 | { | ||
170 | XmlRpcRequest UserReq = new XmlRpcRequest(method, SendParams); | ||
171 | XmlRpcResponse UserResp = UserReq.Send(m_cfg.UserServerURL, 16000); | ||
172 | // Process Response | ||
173 | Hashtable UserRespData = (Hashtable)UserResp.Value; | ||
174 | // if we got a response, we were successful | ||
175 | if (!UserRespData.ContainsKey("responsestring")) | ||
176 | success = false; | ||
177 | } | ||
178 | catch | ||
179 | { | ||
180 | m_log.ErrorFormat("Unable to connect to server {0}. Server not running?", srv); | ||
181 | success = false; | ||
182 | } | ||
183 | } | ||
184 | return success; | ||
185 | } | ||
186 | } | ||
187 | } | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs deleted file mode 100644 index b9d3f22..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs +++ /dev/null | |||
@@ -1,200 +0,0 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Threading; | ||
34 | using System.Timers; | ||
35 | using log4net; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Data; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | using Timer = System.Timers.Timer; | ||
42 | using OpenSim.Services.Interfaces; | ||
43 | using OpenSim.Services.Connectors; | ||
44 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | |||
46 | |||
47 | namespace OpenSim.Grid.MessagingServer.Modules | ||
48 | { | ||
49 | public class MessageRegionModule : IMessageRegionLookup | ||
50 | { | ||
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private MessageServerConfig m_cfg; | ||
54 | |||
55 | private IInterServiceUserService m_userServerModule; | ||
56 | |||
57 | private IGridServiceCore m_messageCore; | ||
58 | |||
59 | private IGridService m_GridService; | ||
60 | |||
61 | // a dictionary of all current regions this server knows about | ||
62 | private Dictionary<ulong, RegionProfileData> m_regionInfoCache = new Dictionary<ulong, RegionProfileData>(); | ||
63 | |||
64 | public MessageRegionModule(MessageServerConfig config, IGridServiceCore messageCore) | ||
65 | { | ||
66 | m_cfg = config; | ||
67 | m_messageCore = messageCore; | ||
68 | |||
69 | m_GridService = new GridServicesConnector(m_cfg.GridServerURL); | ||
70 | } | ||
71 | |||
72 | public void Initialise() | ||
73 | { | ||
74 | m_messageCore.RegisterInterface<IMessageRegionLookup>(this); | ||
75 | } | ||
76 | |||
77 | public void PostInitialise() | ||
78 | { | ||
79 | IInterServiceUserService messageUserServer; | ||
80 | if (m_messageCore.TryGet<IInterServiceUserService>(out messageUserServer)) | ||
81 | { | ||
82 | m_userServerModule = messageUserServer; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | public void RegisterHandlers() | ||
87 | { | ||
88 | //have these in separate method as some servers restart the http server and reregister all the handlers. | ||
89 | |||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// Gets and caches a RegionInfo object from the gridserver based on regionhandle | ||
94 | /// if the regionhandle is already cached, use the cached values | ||
95 | /// Gets called by lots of threads!!!!! | ||
96 | /// </summary> | ||
97 | /// <param name="regionhandle">handle to the XY of the region we're looking for</param> | ||
98 | /// <returns>A RegionInfo object to stick in the presence info</returns> | ||
99 | public RegionProfileData GetRegionInfo(ulong regionhandle) | ||
100 | { | ||
101 | RegionProfileData regionInfo = null; | ||
102 | |||
103 | lock (m_regionInfoCache) | ||
104 | { | ||
105 | m_regionInfoCache.TryGetValue(regionhandle, out regionInfo); | ||
106 | } | ||
107 | |||
108 | if (regionInfo == null) // not found in cache | ||
109 | { | ||
110 | regionInfo = RequestRegionInfo(regionhandle); | ||
111 | |||
112 | if (regionInfo != null) // lookup was successful | ||
113 | { | ||
114 | lock (m_regionInfoCache) | ||
115 | { | ||
116 | m_regionInfoCache[regionhandle] = regionInfo; | ||
117 | } | ||
118 | } | ||
119 | } | ||
120 | |||
121 | return regionInfo; | ||
122 | } | ||
123 | |||
124 | public int ClearRegionCache() | ||
125 | { | ||
126 | int cachecount = 0; | ||
127 | |||
128 | lock (m_regionInfoCache) | ||
129 | { | ||
130 | cachecount = m_regionInfoCache.Count; | ||
131 | m_regionInfoCache.Clear(); | ||
132 | } | ||
133 | |||
134 | return cachecount; | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Get RegionProfileData from the GridServer. | ||
139 | /// We'll cache this information in GetRegionInfo and use it for presence updates | ||
140 | /// </summary> | ||
141 | /// <param name="regionHandle"></param> | ||
142 | /// <returns></returns> | ||
143 | public RegionProfileData RequestRegionInfo(ulong regionHandle) | ||
144 | { | ||
145 | uint x = 0, y = 0; | ||
146 | Utils.LongToUInts(regionHandle, out x, out y); | ||
147 | GridRegion region = m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
148 | |||
149 | if (region != null) | ||
150 | return GridRegionToRegionProfile(region); | ||
151 | |||
152 | else | ||
153 | return null; | ||
154 | } | ||
155 | |||
156 | private RegionProfileData GridRegionToRegionProfile(GridRegion region) | ||
157 | { | ||
158 | RegionProfileData rprofile = new RegionProfileData(); | ||
159 | rprofile.httpPort = region.HttpPort; | ||
160 | rprofile.httpServerURI = region.ServerURI; | ||
161 | rprofile.regionLocX = (uint)(region.RegionLocX / Constants.RegionSize); | ||
162 | rprofile.regionLocY = (uint)(region.RegionLocY / Constants.RegionSize); | ||
163 | rprofile.RegionName = region.RegionName; | ||
164 | rprofile.ServerHttpPort = region.HttpPort; | ||
165 | rprofile.ServerIP = region.ExternalHostName; | ||
166 | rprofile.ServerPort = (uint)region.ExternalEndPoint.Port; | ||
167 | rprofile.Uuid = region.RegionID; | ||
168 | return rprofile; | ||
169 | } | ||
170 | |||
171 | public XmlRpcResponse RegionStartup(XmlRpcRequest request, IPEndPoint remoteClient) | ||
172 | { | ||
173 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
174 | Hashtable result = new Hashtable(); | ||
175 | result["success"] = "FALSE"; | ||
176 | |||
177 | if (m_userServerModule.SendToUserServer(requestData, "region_startup")) | ||
178 | result["success"] = "TRUE"; | ||
179 | |||
180 | XmlRpcResponse response = new XmlRpcResponse(); | ||
181 | response.Value = result; | ||
182 | return response; | ||
183 | } | ||
184 | |||
185 | public XmlRpcResponse RegionShutdown(XmlRpcRequest request, IPEndPoint remoteClient) | ||
186 | { | ||
187 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
188 | Hashtable result = new Hashtable(); | ||
189 | result["success"] = "FALSE"; | ||
190 | |||
191 | if (m_userServerModule.SendToUserServer(requestData, "region_shutdown")) | ||
192 | result["success"] = "TRUE"; | ||
193 | |||
194 | XmlRpcResponse response = new XmlRpcResponse(); | ||
195 | response.Value = result; | ||
196 | return response; | ||
197 | } | ||
198 | |||
199 | } | ||
200 | } \ No newline at end of file | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageService.cs b/OpenSim/Grid/MessagingServer.Modules/MessageService.cs deleted file mode 100644 index 8ad1e9c..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/MessageService.cs +++ /dev/null | |||
@@ -1,503 +0,0 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Threading; | ||
34 | using System.Timers; | ||
35 | using log4net; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Data; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | using Timer=System.Timers.Timer; | ||
42 | |||
43 | namespace OpenSim.Grid.MessagingServer.Modules | ||
44 | { | ||
45 | public class MessageService | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private MessageServerConfig m_cfg; | ||
50 | private UserDataBaseService m_userDataBaseService; | ||
51 | |||
52 | private IGridServiceCore m_messageCore; | ||
53 | |||
54 | private IInterServiceUserService m_userServerModule; | ||
55 | private IMessageRegionLookup m_regionModule; | ||
56 | |||
57 | // a dictionary of all current presences this server knows about | ||
58 | private Dictionary<UUID, UserPresenceData> m_presences = new Dictionary<UUID,UserPresenceData>(); | ||
59 | |||
60 | public MessageService(MessageServerConfig cfg, IGridServiceCore messageCore, UserDataBaseService userDataBaseService) | ||
61 | { | ||
62 | m_cfg = cfg; | ||
63 | m_messageCore = messageCore; | ||
64 | |||
65 | m_userDataBaseService = userDataBaseService; | ||
66 | |||
67 | //??? | ||
68 | UserConfig uc = new UserConfig(); | ||
69 | uc.DatabaseConnect = cfg.DatabaseConnect; | ||
70 | uc.DatabaseProvider = cfg.DatabaseProvider; | ||
71 | } | ||
72 | |||
73 | public void Initialise() | ||
74 | { | ||
75 | } | ||
76 | |||
77 | public void PostInitialise() | ||
78 | { | ||
79 | IInterServiceUserService messageUserServer; | ||
80 | if (m_messageCore.TryGet<IInterServiceUserService>(out messageUserServer)) | ||
81 | { | ||
82 | m_userServerModule = messageUserServer; | ||
83 | } | ||
84 | |||
85 | IMessageRegionLookup messageRegion; | ||
86 | if (m_messageCore.TryGet<IMessageRegionLookup>(out messageRegion)) | ||
87 | { | ||
88 | m_regionModule = messageRegion; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | public void RegisterHandlers() | ||
93 | { | ||
94 | //have these in separate method as some servers restart the http server and reregister all the handlers. | ||
95 | |||
96 | } | ||
97 | |||
98 | #region FriendList Methods | ||
99 | |||
100 | /// <summary> | ||
101 | /// Process Friendlist subscriptions for a user | ||
102 | /// The login method calls this for a User | ||
103 | /// </summary> | ||
104 | /// <param name="userpresence">The Agent we're processing the friendlist subscriptions for</param> | ||
105 | private void ProcessFriendListSubscriptions(UserPresenceData userpresence) | ||
106 | { | ||
107 | lock (m_presences) | ||
108 | { | ||
109 | m_presences[userpresence.agentData.AgentID] = userpresence; | ||
110 | } | ||
111 | |||
112 | Dictionary<UUID, FriendListItem> uFriendList = userpresence.friendData; | ||
113 | foreach (KeyValuePair<UUID, FriendListItem> pair in uFriendList) | ||
114 | { | ||
115 | UserPresenceData friendup = null; | ||
116 | lock (m_presences) | ||
117 | { | ||
118 | m_presences.TryGetValue(pair.Key, out friendup); | ||
119 | } | ||
120 | if (friendup != null) | ||
121 | { | ||
122 | SubscribeToPresenceUpdates(userpresence, friendup, pair.Value); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Enqueues a presence update, sending info about user 'talkingAbout' to user 'receiver'. | ||
129 | /// </summary> | ||
130 | /// <param name="talkingAbout">We are sending presence information about this user.</param> | ||
131 | /// <param name="receiver">We are sending the presence update to this user</param> | ||
132 | private void enqueuePresenceUpdate(UserPresenceData talkingAbout, UserPresenceData receiver) | ||
133 | { | ||
134 | UserAgentData p2Handle = m_userDataBaseService.GetUserAgentData(receiver.agentData.AgentID); | ||
135 | if (p2Handle != null) | ||
136 | { | ||
137 | if (receiver.lookupUserRegionYN) | ||
138 | { | ||
139 | receiver.regionData.regionHandle = p2Handle.Handle; | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | receiver.lookupUserRegionYN = true; // TODO Huh? | ||
144 | } | ||
145 | |||
146 | PresenceInformer friendlistupdater = new PresenceInformer(); | ||
147 | friendlistupdater.presence1 = talkingAbout; | ||
148 | friendlistupdater.presence2 = receiver; | ||
149 | friendlistupdater.OnGetRegionData += m_regionModule.GetRegionInfo; | ||
150 | friendlistupdater.OnDone += PresenceUpdateDone; | ||
151 | Util.FireAndForget(friendlistupdater.go); | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | m_log.WarnFormat("no data found for user {0}", receiver.agentData.AgentID); | ||
156 | // Skip because we can't find any data on the user | ||
157 | } | ||
158 | } | ||
159 | |||
160 | /// <summary> | ||
161 | /// Does the necessary work to subscribe one agent to another's presence notifications | ||
162 | /// Gets called by ProcessFriendListSubscriptions. You shouldn't call this directly | ||
163 | /// unless you know what you're doing | ||
164 | /// </summary> | ||
165 | /// <param name="userpresence">P1</param> | ||
166 | /// <param name="friendpresence">P2</param> | ||
167 | /// <param name="uFriendListItem"></param> | ||
168 | private void SubscribeToPresenceUpdates(UserPresenceData userpresence, | ||
169 | UserPresenceData friendpresence, | ||
170 | FriendListItem uFriendListItem) | ||
171 | { | ||
172 | // Can the friend see me online? | ||
173 | if ((uFriendListItem.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
174 | { | ||
175 | // tell user to update friend about user's presence changes | ||
176 | if (!userpresence.subscriptionData.Contains(friendpresence.agentData.AgentID)) | ||
177 | { | ||
178 | userpresence.subscriptionData.Add(friendpresence.agentData.AgentID); | ||
179 | } | ||
180 | |||
181 | // send an update about user's presence to the friend | ||
182 | enqueuePresenceUpdate(userpresence, friendpresence); | ||
183 | } | ||
184 | |||
185 | // Can I see the friend online? | ||
186 | if ((uFriendListItem.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) | ||
187 | { | ||
188 | // tell friend to update user about friend's presence changes | ||
189 | if (!friendpresence.subscriptionData.Contains(userpresence.agentData.AgentID)) | ||
190 | { | ||
191 | friendpresence.subscriptionData.Add(userpresence.agentData.AgentID); | ||
192 | } | ||
193 | |||
194 | // send an update about friend's presence to user. | ||
195 | enqueuePresenceUpdate(friendpresence, userpresence); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// Logoff Processor. Call this to clean up agent presence data and send logoff presence notifications | ||
201 | /// </summary> | ||
202 | /// <param name="AgentID"></param> | ||
203 | private void ProcessLogOff(UUID AgentID) | ||
204 | { | ||
205 | m_log.Info("[LOGOFF]: Processing Logoff"); | ||
206 | |||
207 | UserPresenceData userPresence = null; | ||
208 | lock (m_presences) | ||
209 | { | ||
210 | m_presences.TryGetValue(AgentID, out userPresence); | ||
211 | } | ||
212 | |||
213 | if (userPresence != null) // found the user | ||
214 | { | ||
215 | List<UUID> AgentsNeedingNotification = userPresence.subscriptionData; | ||
216 | userPresence.OnlineYN = false; | ||
217 | |||
218 | for (int i = 0; i < AgentsNeedingNotification.Count; i++) | ||
219 | { | ||
220 | UserPresenceData friendPresence = null; | ||
221 | lock (m_presences) | ||
222 | { | ||
223 | m_presences.TryGetValue(AgentsNeedingNotification[i], out friendPresence); | ||
224 | } | ||
225 | |||
226 | // This might need to be enumerated and checked before we try to remove it. | ||
227 | if (friendPresence != null) | ||
228 | { | ||
229 | lock (friendPresence) | ||
230 | { | ||
231 | // no updates for this user anymore | ||
232 | friendPresence.subscriptionData.Remove(AgentID); | ||
233 | |||
234 | // set user's entry in the friend's list to offline (if it exists) | ||
235 | if (friendPresence.friendData.ContainsKey(AgentID)) | ||
236 | { | ||
237 | friendPresence.friendData[AgentID].onlinestatus = false; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | enqueuePresenceUpdate(userPresence, friendPresence); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | |||
247 | #endregion | ||
248 | |||
249 | private void PresenceUpdateDone(PresenceInformer obj) | ||
250 | { | ||
251 | obj.OnGetRegionData -= m_regionModule.GetRegionInfo; | ||
252 | obj.OnDone -= PresenceUpdateDone; | ||
253 | } | ||
254 | |||
255 | #region UserServer Comms | ||
256 | |||
257 | /// <summary> | ||
258 | /// Returns a list of FriendsListItems that describe the friends and permissions in the friend | ||
259 | /// relationship for UUID friendslistowner. For faster lookup, we index by friend's UUID. | ||
260 | /// </summary> | ||
261 | /// <param name="friendlistowner">The agent that we're retreiving the friends Data for.</param> | ||
262 | private Dictionary<UUID, FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
263 | { | ||
264 | Dictionary<UUID, FriendListItem> buddies = new Dictionary<UUID,FriendListItem>(); | ||
265 | |||
266 | try | ||
267 | { | ||
268 | Hashtable param = new Hashtable(); | ||
269 | param["ownerID"] = friendlistowner.ToString(); | ||
270 | |||
271 | IList parameters = new ArrayList(); | ||
272 | parameters.Add(param); | ||
273 | XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters); | ||
274 | XmlRpcResponse resp = req.Send(m_cfg.UserServerURL, 3000); | ||
275 | Hashtable respData = (Hashtable)resp.Value; | ||
276 | |||
277 | if (respData.Contains("avcount")) | ||
278 | { | ||
279 | buddies = ConvertXMLRPCDataToFriendListItemList(respData); | ||
280 | } | ||
281 | |||
282 | } | ||
283 | catch (WebException e) | ||
284 | { | ||
285 | m_log.Warn("Error when trying to fetch Avatar's friends list: " + | ||
286 | e.Message); | ||
287 | // Return Empty list (no friends) | ||
288 | } | ||
289 | return buddies; | ||
290 | } | ||
291 | |||
292 | /// <summary> | ||
293 | /// Converts XMLRPC Friend List to FriendListItem Object | ||
294 | /// </summary> | ||
295 | /// <param name="data">XMLRPC response data Hashtable</param> | ||
296 | /// <returns></returns> | ||
297 | public Dictionary<UUID, FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data) | ||
298 | { | ||
299 | Dictionary<UUID, FriendListItem> buddies = new Dictionary<UUID,FriendListItem>(); | ||
300 | int buddycount = Convert.ToInt32((string)data["avcount"]); | ||
301 | |||
302 | for (int i = 0; i < buddycount; i++) | ||
303 | { | ||
304 | FriendListItem buddylistitem = new FriendListItem(); | ||
305 | |||
306 | buddylistitem.FriendListOwner = new UUID((string)data["ownerID" + i.ToString()]); | ||
307 | buddylistitem.Friend = new UUID((string)data["friendID" + i.ToString()]); | ||
308 | buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]); | ||
309 | buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]); | ||
310 | |||
311 | buddies.Add(buddylistitem.Friend, buddylistitem); | ||
312 | } | ||
313 | |||
314 | return buddies; | ||
315 | } | ||
316 | |||
317 | /// <summary> | ||
318 | /// UserServer sends an expect_user method | ||
319 | /// this handles the method and provisions the | ||
320 | /// necessary info for presence to work | ||
321 | /// </summary> | ||
322 | /// <param name="request">UserServer Data</param> | ||
323 | /// <returns></returns> | ||
324 | public XmlRpcResponse UserLoggedOn(XmlRpcRequest request, IPEndPoint remoteClient) | ||
325 | { | ||
326 | try | ||
327 | { | ||
328 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
329 | |||
330 | AgentCircuitData agentData = new AgentCircuitData(); | ||
331 | agentData.SessionID = new UUID((string)requestData["sessionid"]); | ||
332 | agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]); | ||
333 | agentData.firstname = (string)requestData["firstname"]; | ||
334 | agentData.lastname = (string)requestData["lastname"]; | ||
335 | agentData.AgentID = new UUID((string)requestData["agentid"]); | ||
336 | agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | ||
337 | agentData.CapsPath = (string)requestData["caps_path"]; | ||
338 | |||
339 | if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) | ||
340 | { | ||
341 | agentData.child = true; | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | agentData.startpos = | ||
346 | new Vector3(Convert.ToSingle(requestData["positionx"]), | ||
347 | Convert.ToSingle(requestData["positiony"]), | ||
348 | Convert.ToSingle(requestData["positionz"])); | ||
349 | agentData.child = false; | ||
350 | } | ||
351 | |||
352 | ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); | ||
353 | |||
354 | m_log.InfoFormat("[LOGON]: User {0} {1} logged into region {2} as {3} agent, building indexes for user", | ||
355 | agentData.firstname, agentData.lastname, regionHandle, agentData.child ? "child" : "root"); | ||
356 | |||
357 | UserPresenceData up = new UserPresenceData(); | ||
358 | up.agentData = agentData; | ||
359 | up.friendData = GetUserFriendList(agentData.AgentID); | ||
360 | up.regionData = m_regionModule.GetRegionInfo(regionHandle); | ||
361 | up.OnlineYN = true; | ||
362 | up.lookupUserRegionYN = false; | ||
363 | ProcessFriendListSubscriptions(up); | ||
364 | |||
365 | } | ||
366 | catch (Exception e) | ||
367 | { | ||
368 | m_log.WarnFormat("[LOGIN]: Exception on UserLoggedOn: {0}", e); | ||
369 | } | ||
370 | |||
371 | return new XmlRpcResponse(); | ||
372 | |||
373 | } | ||
374 | |||
375 | /// <summary> | ||
376 | /// The UserServer got a Logoff message | ||
377 | /// Cleanup time for that user. Send out presence notifications | ||
378 | /// </summary> | ||
379 | /// <param name="request"></param> | ||
380 | /// <returns></returns> | ||
381 | public XmlRpcResponse UserLoggedOff(XmlRpcRequest request, IPEndPoint remoteClient) | ||
382 | { | ||
383 | try | ||
384 | { | ||
385 | m_log.Info("[USERLOGOFF]: User logged off called"); | ||
386 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
387 | |||
388 | UUID AgentID = new UUID((string)requestData["agentid"]); | ||
389 | ProcessLogOff(AgentID); | ||
390 | } | ||
391 | catch (Exception e) | ||
392 | { | ||
393 | m_log.WarnFormat("[USERLOGOFF]: Exception on UserLoggedOff: {0}", e); | ||
394 | } | ||
395 | |||
396 | return new XmlRpcResponse(); | ||
397 | } | ||
398 | |||
399 | #endregion | ||
400 | |||
401 | public XmlRpcResponse GetPresenceInfoBulk(XmlRpcRequest request, IPEndPoint remoteClient) | ||
402 | { | ||
403 | Hashtable paramHash = (Hashtable)request.Params[0]; | ||
404 | Hashtable result = new Hashtable(); | ||
405 | |||
406 | // TODO check access (recv_key/send_key) | ||
407 | |||
408 | IList list = (IList)paramHash["uuids"]; | ||
409 | |||
410 | // convert into List<UUID> | ||
411 | List<UUID> uuids = new List<UUID>(); | ||
412 | for (int i = 0; i < list.Count; ++i) | ||
413 | { | ||
414 | UUID uuid; | ||
415 | if (UUID.TryParse((string)list[i], out uuid)) | ||
416 | { | ||
417 | uuids.Add(uuid); | ||
418 | } | ||
419 | } | ||
420 | |||
421 | try { | ||
422 | Dictionary<UUID, FriendRegionInfo> infos = m_userDataBaseService.GetFriendRegionInfos(uuids); | ||
423 | m_log.DebugFormat("[FRIEND]: Got {0} region entries back.", infos.Count); | ||
424 | int count = 0; | ||
425 | foreach (KeyValuePair<UUID, FriendRegionInfo> pair in infos) | ||
426 | { | ||
427 | result["uuid_" + count] = pair.Key.ToString(); | ||
428 | result["isOnline_" + count] = pair.Value.isOnline; | ||
429 | result["regionHandle_" + count] = pair.Value.regionHandle.ToString(); // XML-RPC doesn't know ulongs | ||
430 | ++count; | ||
431 | } | ||
432 | result["count"] = count; | ||
433 | |||
434 | XmlRpcResponse response = new XmlRpcResponse(); | ||
435 | response.Value = result; | ||
436 | return response; | ||
437 | } | ||
438 | catch(Exception e) { | ||
439 | m_log.Error("Got exception:", e); | ||
440 | throw e; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | public XmlRpcResponse AgentLocation(XmlRpcRequest request, IPEndPoint remoteClient) | ||
445 | { | ||
446 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
447 | Hashtable result = new Hashtable(); | ||
448 | result["success"] = "FALSE"; | ||
449 | |||
450 | if (m_userServerModule.SendToUserServer(requestData, "agent_location")) | ||
451 | result["success"] = "TRUE"; | ||
452 | |||
453 | |||
454 | XmlRpcResponse response = new XmlRpcResponse(); | ||
455 | response.Value = result; | ||
456 | return response; | ||
457 | } | ||
458 | |||
459 | public XmlRpcResponse AgentLeaving(XmlRpcRequest request, IPEndPoint remoteClient) | ||
460 | { | ||
461 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
462 | Hashtable result = new Hashtable(); | ||
463 | result["success"] = "FALSE"; | ||
464 | |||
465 | if (m_userServerModule.SendToUserServer(requestData, "agent_leaving")) | ||
466 | result["success"] = "TRUE"; | ||
467 | |||
468 | XmlRpcResponse response = new XmlRpcResponse(); | ||
469 | response.Value = result; | ||
470 | return response; | ||
471 | } | ||
472 | |||
473 | public XmlRpcResponse ProcessRegionShutdown(XmlRpcRequest request, IPEndPoint remoteClient) | ||
474 | { | ||
475 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
476 | Hashtable result = new Hashtable(); | ||
477 | result["success"] = "FALSE"; | ||
478 | |||
479 | UUID regionID; | ||
480 | if (UUID.TryParse((string)requestData["regionid"], out regionID)) | ||
481 | { | ||
482 | m_log.DebugFormat("[PRESENCE] Processing region restart for {0}", regionID); | ||
483 | result["success"] = "TRUE"; | ||
484 | |||
485 | foreach (UserPresenceData up in m_presences.Values) | ||
486 | { | ||
487 | if (up.regionData.UUID == regionID) | ||
488 | { | ||
489 | if (up.OnlineYN) | ||
490 | { | ||
491 | m_log.DebugFormat("[PRESENCE] Logging off {0} because the region they were in has gone", up.agentData.AgentID); | ||
492 | ProcessLogOff(up.agentData.AgentID); | ||
493 | } | ||
494 | } | ||
495 | } | ||
496 | } | ||
497 | |||
498 | XmlRpcResponse response = new XmlRpcResponse(); | ||
499 | response.Value = result; | ||
500 | return response; | ||
501 | } | ||
502 | } | ||
503 | } \ No newline at end of file | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/PresenceInformer.cs b/OpenSim/Grid/MessagingServer.Modules/PresenceInformer.cs deleted file mode 100644 index 97126f7..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/PresenceInformer.cs +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
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.Collections; | ||
29 | using System.Net; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nwc.XmlRpc; | ||
33 | using OpenSim.Data; | ||
34 | |||
35 | namespace OpenSim.Grid.MessagingServer.Modules | ||
36 | { | ||
37 | public delegate RegionProfileData GetRegionData(ulong region_handle); | ||
38 | public delegate void Done(PresenceInformer obj); | ||
39 | |||
40 | |||
41 | public class PresenceInformer | ||
42 | { | ||
43 | public event GetRegionData OnGetRegionData; | ||
44 | public event Done OnDone; | ||
45 | |||
46 | private GetRegionData handlerGetRegionData = null; | ||
47 | private Done handlerDone = null; | ||
48 | |||
49 | public UserPresenceData presence1 = null; | ||
50 | public UserPresenceData presence2 = null; | ||
51 | public string gridserverurl, gridserversendkey, gridserverrecvkey; | ||
52 | public bool lookupRegion = true; | ||
53 | //public methodGroup | ||
54 | |||
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
56 | |||
57 | public PresenceInformer() | ||
58 | { | ||
59 | |||
60 | } | ||
61 | public void go(object o) | ||
62 | { | ||
63 | if (presence1 != null && presence2 != null) | ||
64 | { | ||
65 | SendRegionPresenceUpdate(presence1, presence2); | ||
66 | } | ||
67 | |||
68 | } | ||
69 | |||
70 | /// <summary> | ||
71 | /// Informs a region about an Agent | ||
72 | /// </summary> | ||
73 | /// <param name="TalkingAbout">User to talk about</param> | ||
74 | /// <param name="UserToUpdate">User we're sending this too (contains the region)</param> | ||
75 | public void SendRegionPresenceUpdate(UserPresenceData TalkingAbout, UserPresenceData UserToUpdate) | ||
76 | { | ||
77 | // TODO: Fill in pertenant Presence Data from 'TalkingAbout' | ||
78 | RegionProfileData whichRegion = new RegionProfileData(); | ||
79 | if (lookupRegion) | ||
80 | { | ||
81 | handlerGetRegionData = OnGetRegionData; | ||
82 | if (handlerGetRegionData != null) | ||
83 | { | ||
84 | whichRegion = handlerGetRegionData(UserToUpdate.regionData.regionHandle); | ||
85 | } | ||
86 | //RegionProfileData rp = RegionProfileData.RequestSimProfileData(UserToUpdate.regionData.regionHandle, gridserverurl, gridserversendkey, gridserverrecvkey); | ||
87 | |||
88 | //whichRegion = rp; | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | whichRegion = UserToUpdate.regionData; | ||
93 | } | ||
94 | //whichRegion.httpServerURI | ||
95 | |||
96 | if (whichRegion != null) | ||
97 | { | ||
98 | Hashtable PresenceParams = new Hashtable(); | ||
99 | PresenceParams.Add("agent_id",TalkingAbout.agentData.AgentID.ToString()); | ||
100 | PresenceParams.Add("notify_id",UserToUpdate.agentData.AgentID.ToString()); | ||
101 | if (TalkingAbout.OnlineYN) | ||
102 | PresenceParams.Add("status","TRUE"); | ||
103 | else | ||
104 | PresenceParams.Add("status","FALSE"); | ||
105 | |||
106 | ArrayList SendParams = new ArrayList(); | ||
107 | SendParams.Add(PresenceParams); | ||
108 | |||
109 | m_log.InfoFormat("[PRESENCE]: Informing {0}@{1} at {2} about {3}", TalkingAbout.agentData.firstname + " " + TalkingAbout.agentData.lastname, whichRegion.regionName, whichRegion.httpServerURI, UserToUpdate.agentData.firstname + " " + UserToUpdate.agentData.lastname); | ||
110 | // Send | ||
111 | XmlRpcRequest RegionReq = new XmlRpcRequest("presence_update", SendParams); | ||
112 | try | ||
113 | { | ||
114 | // XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000); | ||
115 | RegionReq.Send(whichRegion.httpServerURI, 6000); | ||
116 | } | ||
117 | catch (WebException) | ||
118 | { | ||
119 | m_log.WarnFormat("[INFORM]: failed notifying region {0} containing user {1} about {2}", whichRegion.regionName, UserToUpdate.agentData.firstname + " " + UserToUpdate.agentData.lastname, TalkingAbout.agentData.firstname + " " + TalkingAbout.agentData.lastname); | ||
120 | } | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | m_log.Info("[PRESENCEUPDATER]: Region data was null skipping"); | ||
125 | |||
126 | } | ||
127 | |||
128 | handlerDone = OnDone; | ||
129 | if (handlerDone != null) | ||
130 | { | ||
131 | handlerDone(this); | ||
132 | } | ||
133 | } | ||
134 | } | ||
135 | } | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/PresenceService.cs b/OpenSim/Grid/MessagingServer.Modules/PresenceService.cs deleted file mode 100644 index 7487a21..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/PresenceService.cs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 | namespace OpenSim.Grid.MessagingServer.Modules | ||
29 | { | ||
30 | class PresenceService | ||
31 | { | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/WorkUnitBase.cs b/OpenSim/Grid/MessagingServer.Modules/WorkUnitBase.cs deleted file mode 100644 index f740339..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/WorkUnitBase.cs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 | namespace OpenSim.Grid.MessagingServer.Modules | ||
29 | { | ||
30 | public class WorkUnitBase | ||
31 | { | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/WorkUnitPresenceUpdate.cs b/OpenSim/Grid/MessagingServer.Modules/WorkUnitPresenceUpdate.cs deleted file mode 100644 index 7f11e66..0000000 --- a/OpenSim/Grid/MessagingServer.Modules/WorkUnitPresenceUpdate.cs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 | namespace OpenSim.Grid.MessagingServer.Modules | ||
29 | { | ||
30 | public class WorkUnitPresenceUpdate : WorkUnitBase | ||
31 | { | ||
32 | } | ||
33 | } | ||
diff --git a/OpenSim/Grid/MessagingServer.Modules/UserPresenceData.cs b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs index 7d4e45c..c9e80d9 100644 --- a/OpenSim/Grid/MessagingServer.Modules/UserPresenceData.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -27,24 +27,29 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
31 | using log4net; | ||
30 | using OpenMetaverse; | 32 | using OpenMetaverse; |
31 | using OpenSim.Data; | 33 | using Nini.Config; |
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | using OpenSim.Server.Handlers.Base; | ||
33 | 37 | ||
34 | namespace OpenSim.Grid.MessagingServer | 38 | namespace OpenSim.Server.Handlers.Grid |
35 | { | 39 | { |
36 | public class UserPresenceData | 40 | public class GridInfoServerInConnector : ServiceConnector |
37 | { | 41 | { |
38 | public AgentCircuitData agentData = new AgentCircuitData(); | 42 | private string m_ConfigName = "GridInfoService"; |
39 | public RegionProfileData regionData = new RegionProfileData(); | ||
40 | public string httpURI = String.Empty; | ||
41 | public Dictionary<UUID, FriendListItem> friendData = new Dictionary<UUID,FriendListItem>(); | ||
42 | public List<UUID> subscriptionData = new List<UUID>(); | ||
43 | public bool OnlineYN = true; | ||
44 | public bool lookupUserRegionYN = true; | ||
45 | 43 | ||
46 | public UserPresenceData() | 44 | public GridInfoServerInConnector(IConfigSource config, IHttpServer server, string configName) : |
45 | base(config, server, configName) | ||
47 | { | 46 | { |
47 | GridInfoHandlers handlers = new GridInfoHandlers(config); | ||
48 | |||
49 | server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", | ||
50 | handlers.RestGetGridInfoMethod)); | ||
51 | server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); | ||
48 | } | 52 | } |
53 | |||
49 | } | 54 | } |
50 | } | 55 | } |