aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs')
-rw-r--r--OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs1018
1 files changed, 509 insertions, 509 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
index b98c614..59e9805 100644
--- a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
@@ -1,509 +1,509 @@
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 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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 27
28using System.Collections; 28using System.Collections;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net; 33using log4net;
34using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38 38
39namespace OpenSim.Grid.UserServer.Modules 39namespace OpenSim.Grid.UserServer.Modules
40{ 40{
41 public enum NotificationRequest : int 41 public enum NotificationRequest : int
42 { 42 {
43 Login = 0, 43 Login = 0,
44 Logout = 1, 44 Logout = 1,
45 Shutdown = 2 45 Shutdown = 2
46 } 46 }
47 47
48 public struct PresenceNotification 48 public struct PresenceNotification
49 { 49 {
50 public NotificationRequest request; 50 public NotificationRequest request;
51 public UUID agentID; 51 public UUID agentID;
52 public UUID sessionID; 52 public UUID sessionID;
53 public UUID RegionID; 53 public UUID RegionID;
54 public ulong regionhandle; 54 public ulong regionhandle;
55 public float positionX; 55 public float positionX;
56 public float positionY; 56 public float positionY;
57 public float positionZ; 57 public float positionZ;
58 public string firstname; 58 public string firstname;
59 public string lastname; 59 public string lastname;
60 } 60 }
61 61
62 public delegate void AgentLocationDelegate(UUID agentID, UUID regionID, ulong regionHandle); 62 public delegate void AgentLocationDelegate(UUID agentID, UUID regionID, ulong regionHandle);
63 public delegate void AgentLeavingDelegate(UUID agentID, UUID regionID, ulong regionHandle); 63 public delegate void AgentLeavingDelegate(UUID agentID, UUID regionID, ulong regionHandle);
64 public delegate void RegionStartupDelegate(UUID regionID); 64 public delegate void RegionStartupDelegate(UUID regionID);
65 public delegate void RegionShutdownDelegate(UUID regionID); 65 public delegate void RegionShutdownDelegate(UUID regionID);
66 66
67 67
68 public class MessageServersConnector 68 public class MessageServersConnector
69 { 69 {
70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
71 71
72 public Dictionary<string, MessageServerInfo> MessageServers; 72 public Dictionary<string, MessageServerInfo> MessageServers;
73 73
74 private BaseHttpServer m_httpServer; 74 private BaseHttpServer m_httpServer;
75 75
76 private BlockingQueue<PresenceNotification> m_NotifyQueue = 76 private BlockingQueue<PresenceNotification> m_NotifyQueue =
77 new BlockingQueue<PresenceNotification>(); 77 new BlockingQueue<PresenceNotification>();
78 78
79 Thread m_NotifyThread; 79 Thread m_NotifyThread;
80 80
81 public event AgentLocationDelegate OnAgentLocation; 81 public event AgentLocationDelegate OnAgentLocation;
82 public event AgentLeavingDelegate OnAgentLeaving; 82 public event AgentLeavingDelegate OnAgentLeaving;
83 public event RegionStartupDelegate OnRegionStartup; 83 public event RegionStartupDelegate OnRegionStartup;
84 public event RegionShutdownDelegate OnRegionShutdown; 84 public event RegionShutdownDelegate OnRegionShutdown;
85 85
86 public MessageServersConnector() 86 public MessageServersConnector()
87 { 87 {
88 MessageServers = new Dictionary<string, MessageServerInfo>(); 88 MessageServers = new Dictionary<string, MessageServerInfo>();
89 m_NotifyThread = new Thread(new ThreadStart(NotifyQueueRunner)); 89 m_NotifyThread = new Thread(new ThreadStart(NotifyQueueRunner));
90 m_NotifyThread.Start(); 90 m_NotifyThread.Start();
91 } 91 }
92 92
93 public void Initialise() 93 public void Initialise()
94 { 94 {
95 95
96 } 96 }
97 97
98 public void PostInitialise() 98 public void PostInitialise()
99 { 99 {
100 100
101 } 101 }
102 102
103 public void RegisterHandlers(BaseHttpServer httpServer) 103 public void RegisterHandlers(BaseHttpServer httpServer)
104 { 104 {
105 m_httpServer = httpServer; 105 m_httpServer = httpServer;
106 106
107 m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup); 107 m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup);
108 m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown); 108 m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown);
109 m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation); 109 m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation);
110 m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving); 110 m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving);
111 // Message Server ---> User Server 111 // Message Server ---> User Server
112 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer); 112 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
113 m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion); 113 m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion);
114 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); 114 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
115 } 115 }
116 116
117 public void RegisterMessageServer(string URI, MessageServerInfo serverData) 117 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
118 { 118 {
119 lock (MessageServers) 119 lock (MessageServers)
120 { 120 {
121 if (!MessageServers.ContainsKey(URI)) 121 if (!MessageServers.ContainsKey(URI))
122 MessageServers.Add(URI, serverData); 122 MessageServers.Add(URI, serverData);
123 } 123 }
124 } 124 }
125 125
126 public void DeRegisterMessageServer(string URI) 126 public void DeRegisterMessageServer(string URI)
127 { 127 {
128 lock (MessageServers) 128 lock (MessageServers)
129 { 129 {
130 if (MessageServers.ContainsKey(URI)) 130 if (MessageServers.ContainsKey(URI))
131 MessageServers.Remove(URI); 131 MessageServers.Remove(URI);
132 } 132 }
133 } 133 }
134 134
135 public void AddResponsibleRegion(string URI, ulong regionhandle) 135 public void AddResponsibleRegion(string URI, ulong regionhandle)
136 { 136 {
137 if (!MessageServers.ContainsKey(URI)) 137 if (!MessageServers.ContainsKey(URI))
138 { 138 {
139 m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered"); 139 m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered");
140 } 140 }
141 else 141 else
142 { 142 {
143 MessageServerInfo msginfo = MessageServers["URI"]; 143 MessageServerInfo msginfo = MessageServers["URI"];
144 msginfo.responsibleForRegions.Add(regionhandle); 144 msginfo.responsibleForRegions.Add(regionhandle);
145 MessageServers["URI"] = msginfo; 145 MessageServers["URI"] = msginfo;
146 } 146 }
147 } 147 }
148 public void RemoveResponsibleRegion(string URI, ulong regionhandle) 148 public void RemoveResponsibleRegion(string URI, ulong regionhandle)
149 { 149 {
150 if (!MessageServers.ContainsKey(URI)) 150 if (!MessageServers.ContainsKey(URI))
151 { 151 {
152 m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered"); 152 m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
153 } 153 }
154 else 154 else
155 { 155 {
156 MessageServerInfo msginfo = MessageServers["URI"]; 156 MessageServerInfo msginfo = MessageServers["URI"];
157 if (msginfo.responsibleForRegions.Contains(regionhandle)) 157 if (msginfo.responsibleForRegions.Contains(regionhandle))
158 { 158 {
159 msginfo.responsibleForRegions.Remove(regionhandle); 159 msginfo.responsibleForRegions.Remove(regionhandle);
160 MessageServers["URI"] = msginfo; 160 MessageServers["URI"] = msginfo;
161 } 161 }
162 } 162 }
163 163
164 } 164 }
165 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) 165 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
166 { 166 {
167 XmlRpcResponse response = new XmlRpcResponse(); 167 XmlRpcResponse response = new XmlRpcResponse();
168 Hashtable requestData = (Hashtable)request.Params[0]; 168 Hashtable requestData = (Hashtable)request.Params[0];
169 Hashtable responseData = new Hashtable(); 169 Hashtable responseData = new Hashtable();
170 170
171 if (requestData.Contains("uri")) 171 if (requestData.Contains("uri"))
172 { 172 {
173 string URI = (string)requestData["uri"]; 173 string URI = (string)requestData["uri"];
174 string sendkey=(string)requestData["sendkey"]; 174 string sendkey=(string)requestData["sendkey"];
175 string recvkey=(string)requestData["recvkey"]; 175 string recvkey=(string)requestData["recvkey"];
176 MessageServerInfo m = new MessageServerInfo(); 176 MessageServerInfo m = new MessageServerInfo();
177 m.URI = URI; 177 m.URI = URI;
178 m.sendkey = sendkey; 178 m.sendkey = sendkey;
179 m.recvkey = recvkey; 179 m.recvkey = recvkey;
180 RegisterMessageServer(URI, m); 180 RegisterMessageServer(URI, m);
181 responseData["responsestring"] = "TRUE"; 181 responseData["responsestring"] = "TRUE";
182 response.Value = responseData; 182 response.Value = responseData;
183 } 183 }
184 return response; 184 return response;
185 } 185 }
186 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) 186 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
187 { 187 {
188 XmlRpcResponse response = new XmlRpcResponse(); 188 XmlRpcResponse response = new XmlRpcResponse();
189 Hashtable requestData = (Hashtable)request.Params[0]; 189 Hashtable requestData = (Hashtable)request.Params[0];
190 Hashtable responseData = new Hashtable(); 190 Hashtable responseData = new Hashtable();
191 191
192 if (requestData.Contains("uri")) 192 if (requestData.Contains("uri"))
193 { 193 {
194 string URI = (string)requestData["uri"]; 194 string URI = (string)requestData["uri"];
195 195
196 DeRegisterMessageServer(URI); 196 DeRegisterMessageServer(URI);
197 responseData["responsestring"] = "TRUE"; 197 responseData["responsestring"] = "TRUE";
198 response.Value = responseData; 198 response.Value = responseData;
199 } 199 }
200 return response; 200 return response;
201 } 201 }
202 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request) 202 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request)
203 { 203 {
204 XmlRpcResponse response = new XmlRpcResponse(); 204 XmlRpcResponse response = new XmlRpcResponse();
205 Hashtable requestData = (Hashtable)request.Params[0]; 205 Hashtable requestData = (Hashtable)request.Params[0];
206 Hashtable responseData = new Hashtable(); 206 Hashtable responseData = new Hashtable();
207 207
208 if (requestData.Contains("fromuri")) 208 if (requestData.Contains("fromuri"))
209 { 209 {
210 // string sURI = (string)requestData["fromuri"]; 210 // string sURI = (string)requestData["fromuri"];
211 // string sagentID = (string)requestData["agentid"]; 211 // string sagentID = (string)requestData["agentid"];
212 // string ssessionID = (string)requestData["sessionid"]; 212 // string ssessionID = (string)requestData["sessionid"];
213 // string scurrentRegionID = (string)requestData["regionid"]; 213 // string scurrentRegionID = (string)requestData["regionid"];
214 // string sregionhandle = (string)requestData["regionhandle"]; 214 // string sregionhandle = (string)requestData["regionhandle"];
215 // string scurrentpos = (string)requestData["currentpos"]; 215 // string scurrentpos = (string)requestData["currentpos"];
216 //Vector3.TryParse((string)reader["currentPos"], out retval.currentPos); 216 //Vector3.TryParse((string)reader["currentPos"], out retval.currentPos);
217 // TODO: Okay now raise event so the user server can pass this data to the Usermanager 217 // TODO: Okay now raise event so the user server can pass this data to the Usermanager
218 218
219 responseData["responsestring"] = "TRUE"; 219 responseData["responsestring"] = "TRUE";
220 response.Value = responseData; 220 response.Value = responseData;
221 } 221 }
222 return response; 222 return response;
223 } 223 }
224 224
225 public void TellMessageServersAboutUser(UUID agentID, UUID sessionID, UUID RegionID, 225 public void TellMessageServersAboutUser(UUID agentID, UUID sessionID, UUID RegionID,
226 ulong regionhandle, float positionX, float positionY, 226 ulong regionhandle, float positionX, float positionY,
227 float positionZ, string firstname, string lastname) 227 float positionZ, string firstname, string lastname)
228 { 228 {
229 PresenceNotification notification = new PresenceNotification(); 229 PresenceNotification notification = new PresenceNotification();
230 230
231 notification.request = NotificationRequest.Login; 231 notification.request = NotificationRequest.Login;
232 notification.agentID = agentID; 232 notification.agentID = agentID;
233 notification.sessionID = sessionID; 233 notification.sessionID = sessionID;
234 notification.RegionID = RegionID; 234 notification.RegionID = RegionID;
235 notification.regionhandle = regionhandle; 235 notification.regionhandle = regionhandle;
236 notification.positionX = positionX; 236 notification.positionX = positionX;
237 notification.positionY = positionY; 237 notification.positionY = positionY;
238 notification.positionZ = positionZ; 238 notification.positionZ = positionZ;
239 notification.firstname = firstname; 239 notification.firstname = firstname;
240 notification.lastname = lastname; 240 notification.lastname = lastname;
241 241
242 m_NotifyQueue.Enqueue(notification); 242 m_NotifyQueue.Enqueue(notification);
243 } 243 }
244 244
245 private void TellMessageServersAboutUserInternal(UUID agentID, UUID sessionID, UUID RegionID, 245 private void TellMessageServersAboutUserInternal(UUID agentID, UUID sessionID, UUID RegionID,
246 ulong regionhandle, float positionX, float positionY, 246 ulong regionhandle, float positionX, float positionY,
247 float positionZ, string firstname, string lastname) 247 float positionZ, string firstname, string lastname)
248 { 248 {
249 // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D) 249 // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D)
250 lock (MessageServers) 250 lock (MessageServers)
251 { 251 {
252 if (MessageServers.Count > 0) 252 if (MessageServers.Count > 0)
253 { 253 {
254 m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers"); 254 m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers");
255 } 255 }
256// else 256// else
257// { 257// {
258// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); 258// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
259// } 259// }
260 foreach (MessageServerInfo serv in MessageServers.Values) 260 foreach (MessageServerInfo serv in MessageServers.Values)
261 { 261 {
262 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, 262 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID,
263 regionhandle, positionX, positionY, positionZ, 263 regionhandle, positionX, positionY, positionZ,
264 firstname, lastname); 264 firstname, lastname);
265 } 265 }
266 } 266 }
267 } 267 }
268 268
269 private void TellMessageServersAboutUserLogoffInternal(UUID agentID) 269 private void TellMessageServersAboutUserLogoffInternal(UUID agentID)
270 { 270 {
271 lock (MessageServers) 271 lock (MessageServers)
272 { 272 {
273 if (MessageServers.Count > 0) 273 if (MessageServers.Count > 0)
274 { 274 {
275 m_log.Info("[MSGCONNECTOR]: Sending logoff notice to registered message servers"); 275 m_log.Info("[MSGCONNECTOR]: Sending logoff notice to registered message servers");
276 } 276 }
277 else 277 else
278 { 278 {
279// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); 279// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
280 } 280 }
281 foreach (MessageServerInfo serv in MessageServers.Values) 281 foreach (MessageServerInfo serv in MessageServers.Values)
282 { 282 {
283 NotifyMessageServerAboutUserLogoff(serv,agentID); 283 NotifyMessageServerAboutUserLogoff(serv,agentID);
284 } 284 }
285 } 285 }
286 } 286 }
287 287
288 private void TellMessageServersAboutRegionShutdownInternal(UUID regionID) 288 private void TellMessageServersAboutRegionShutdownInternal(UUID regionID)
289 { 289 {
290 lock (MessageServers) 290 lock (MessageServers)
291 { 291 {
292 if (MessageServers.Count > 0) 292 if (MessageServers.Count > 0)
293 { 293 {
294 m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers"); 294 m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers");
295 } 295 }
296 else 296 else
297 { 297 {
298// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); 298// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
299 } 299 }
300 foreach (MessageServerInfo serv in MessageServers.Values) 300 foreach (MessageServerInfo serv in MessageServers.Values)
301 { 301 {
302 NotifyMessageServerAboutRegionShutdown(serv,regionID); 302 NotifyMessageServerAboutRegionShutdown(serv,regionID);
303 } 303 }
304 } 304 }
305 } 305 }
306 306
307 public void TellMessageServersAboutUserLogoff(UUID agentID) 307 public void TellMessageServersAboutUserLogoff(UUID agentID)
308 { 308 {
309 PresenceNotification notification = new PresenceNotification(); 309 PresenceNotification notification = new PresenceNotification();
310 310
311 notification.request = NotificationRequest.Logout; 311 notification.request = NotificationRequest.Logout;
312 notification.agentID = agentID; 312 notification.agentID = agentID;
313 313
314 m_NotifyQueue.Enqueue(notification); 314 m_NotifyQueue.Enqueue(notification);
315 } 315 }
316 316
317 public void TellMessageServersAboutRegionShutdown(UUID regionID) 317 public void TellMessageServersAboutRegionShutdown(UUID regionID)
318 { 318 {
319 PresenceNotification notification = new PresenceNotification(); 319 PresenceNotification notification = new PresenceNotification();
320 320
321 notification.request = NotificationRequest.Shutdown; 321 notification.request = NotificationRequest.Shutdown;
322 notification.RegionID = regionID; 322 notification.RegionID = regionID;
323 323
324 m_NotifyQueue.Enqueue(notification); 324 m_NotifyQueue.Enqueue(notification);
325 } 325 }
326 326
327 private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID) 327 private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID)
328 { 328 {
329 Hashtable reqparams = new Hashtable(); 329 Hashtable reqparams = new Hashtable();
330 reqparams["sendkey"] = serv.sendkey; 330 reqparams["sendkey"] = serv.sendkey;
331 reqparams["agentid"] = agentID.ToString(); 331 reqparams["agentid"] = agentID.ToString();
332 ArrayList SendParams = new ArrayList(); 332 ArrayList SendParams = new ArrayList();
333 SendParams.Add(reqparams); 333 SendParams.Add(reqparams);
334 334
335 XmlRpcRequest GridReq = new XmlRpcRequest("logout_of_simulator", SendParams); 335 XmlRpcRequest GridReq = new XmlRpcRequest("logout_of_simulator", SendParams);
336 try 336 try
337 { 337 {
338 GridReq.Send(serv.URI, 6000); 338 GridReq.Send(serv.URI, 6000);
339 } 339 }
340 catch (WebException) 340 catch (WebException)
341 { 341 {
342 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about log out. Other users might still think this user is online"); 342 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about log out. Other users might still think this user is online");
343 } 343 }
344 m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout"); 344 m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout");
345 } 345 }
346 346
347 private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID) 347 private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID)
348 { 348 {
349 Hashtable reqparams = new Hashtable(); 349 Hashtable reqparams = new Hashtable();
350 reqparams["sendkey"] = serv.sendkey; 350 reqparams["sendkey"] = serv.sendkey;
351 reqparams["regionid"] = regionID.ToString(); 351 reqparams["regionid"] = regionID.ToString();
352 ArrayList SendParams = new ArrayList(); 352 ArrayList SendParams = new ArrayList();
353 SendParams.Add(reqparams); 353 SendParams.Add(reqparams);
354 354
355 XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams); 355 XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams);
356 try 356 try
357 { 357 {
358 GridReq.Send(serv.URI, 6000); 358 GridReq.Send(serv.URI, 6000);
359 } 359 }
360 catch (WebException) 360 catch (WebException)
361 { 361 {
362 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown."); 362 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown.");
363 } 363 }
364 m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change"); 364 m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change");
365 } 365 }
366 366
367 private void NotifyMessageServerAboutUser(MessageServerInfo serv, 367 private void NotifyMessageServerAboutUser(MessageServerInfo serv,
368 UUID agentID, UUID sessionID, UUID RegionID, 368 UUID agentID, UUID sessionID, UUID RegionID,
369 ulong regionhandle, float positionX, float positionY, float positionZ, 369 ulong regionhandle, float positionX, float positionY, float positionZ,
370 string firstname, string lastname) 370 string firstname, string lastname)
371 { 371 {
372 Hashtable reqparams = new Hashtable(); 372 Hashtable reqparams = new Hashtable();
373 reqparams["sendkey"] = serv.sendkey; 373 reqparams["sendkey"] = serv.sendkey;
374 reqparams["agentid"] = agentID.ToString(); 374 reqparams["agentid"] = agentID.ToString();
375 reqparams["sessionid"] = sessionID.ToString(); 375 reqparams["sessionid"] = sessionID.ToString();
376 reqparams["regionid"] = RegionID.ToString(); 376 reqparams["regionid"] = RegionID.ToString();
377 reqparams["regionhandle"] = regionhandle.ToString(); 377 reqparams["regionhandle"] = regionhandle.ToString();
378 reqparams["positionx"] = positionX.ToString(); 378 reqparams["positionx"] = positionX.ToString();
379 reqparams["positiony"] = positionY.ToString(); 379 reqparams["positiony"] = positionY.ToString();
380 reqparams["positionz"] = positionZ.ToString(); 380 reqparams["positionz"] = positionZ.ToString();
381 reqparams["firstname"] = firstname; 381 reqparams["firstname"] = firstname;
382 reqparams["lastname"] = lastname; 382 reqparams["lastname"] = lastname;
383 383
384 //reqparams["position"] = Position.ToString(); 384 //reqparams["position"] = Position.ToString();
385 385
386 ArrayList SendParams = new ArrayList(); 386 ArrayList SendParams = new ArrayList();
387 SendParams.Add(reqparams); 387 SendParams.Add(reqparams);
388 388
389 XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams); 389 XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
390 try 390 try
391 { 391 {
392 GridReq.Send(serv.URI, 6000); 392 GridReq.Send(serv.URI, 6000);
393 m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login"); 393 m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
394 } 394 }
395 catch (WebException) 395 catch (WebException)
396 { 396 {
397 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user"); 397 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user");
398 } 398 }
399 399
400 } 400 }
401 401
402 private void NotifyQueueRunner() 402 private void NotifyQueueRunner()
403 { 403 {
404 while (true) 404 while (true)
405 { 405 {
406 PresenceNotification presence = m_NotifyQueue.Dequeue(); 406 PresenceNotification presence = m_NotifyQueue.Dequeue();
407 407
408 if (presence.request == NotificationRequest.Shutdown) 408 if (presence.request == NotificationRequest.Shutdown)
409 { 409 {
410 TellMessageServersAboutRegionShutdownInternal(presence.RegionID); 410 TellMessageServersAboutRegionShutdownInternal(presence.RegionID);
411 } 411 }
412 412
413 if (presence.request == NotificationRequest.Login) 413 if (presence.request == NotificationRequest.Login)
414 { 414 {
415 TellMessageServersAboutUserInternal(presence.agentID, 415 TellMessageServersAboutUserInternal(presence.agentID,
416 presence.sessionID, presence.RegionID, 416 presence.sessionID, presence.RegionID,
417 presence.regionhandle, presence.positionX, 417 presence.regionhandle, presence.positionX,
418 presence.positionY, presence.positionZ, 418 presence.positionY, presence.positionZ,
419 presence.firstname, presence.lastname); 419 presence.firstname, presence.lastname);
420 } 420 }
421 421
422 if (presence.request == NotificationRequest.Logout) 422 if (presence.request == NotificationRequest.Logout)
423 { 423 {
424 TellMessageServersAboutUserLogoffInternal(presence.agentID); 424 TellMessageServersAboutUserLogoffInternal(presence.agentID);
425 } 425 }
426 } 426 }
427 } 427 }
428 428
429 public XmlRpcResponse RegionStartup(XmlRpcRequest request) 429 public XmlRpcResponse RegionStartup(XmlRpcRequest request)
430 { 430 {
431 Hashtable requestData = (Hashtable)request.Params[0]; 431 Hashtable requestData = (Hashtable)request.Params[0];
432 Hashtable result = new Hashtable(); 432 Hashtable result = new Hashtable();
433 433
434 UUID regionID; 434 UUID regionID;
435 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID)) 435 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
436 { 436 {
437 if (OnRegionStartup != null) 437 if (OnRegionStartup != null)
438 OnRegionStartup(regionID); 438 OnRegionStartup(regionID);
439 439
440 result["responsestring"] = "TRUE"; 440 result["responsestring"] = "TRUE";
441 } 441 }
442 442
443 XmlRpcResponse response = new XmlRpcResponse(); 443 XmlRpcResponse response = new XmlRpcResponse();
444 response.Value = result; 444 response.Value = result;
445 return response; 445 return response;
446 } 446 }
447 447
448 public XmlRpcResponse RegionShutdown(XmlRpcRequest request) 448 public XmlRpcResponse RegionShutdown(XmlRpcRequest request)
449 { 449 {
450 Hashtable requestData = (Hashtable)request.Params[0]; 450 Hashtable requestData = (Hashtable)request.Params[0];
451 Hashtable result = new Hashtable(); 451 Hashtable result = new Hashtable();
452 452
453 UUID regionID; 453 UUID regionID;
454 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID)) 454 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
455 { 455 {
456 if (OnRegionShutdown != null) 456 if (OnRegionShutdown != null)
457 OnRegionShutdown(regionID); 457 OnRegionShutdown(regionID);
458 458
459 result["responsestring"] = "TRUE"; 459 result["responsestring"] = "TRUE";
460 } 460 }
461 461
462 XmlRpcResponse response = new XmlRpcResponse(); 462 XmlRpcResponse response = new XmlRpcResponse();
463 response.Value = result; 463 response.Value = result;
464 return response; 464 return response;
465 } 465 }
466 466
467 public XmlRpcResponse AgentLocation(XmlRpcRequest request) 467 public XmlRpcResponse AgentLocation(XmlRpcRequest request)
468 { 468 {
469 Hashtable requestData = (Hashtable)request.Params[0]; 469 Hashtable requestData = (Hashtable)request.Params[0];
470 Hashtable result = new Hashtable(); 470 Hashtable result = new Hashtable();
471 471
472 UUID agentID; 472 UUID agentID;
473 UUID regionID; 473 UUID regionID;
474 ulong regionHandle; 474 ulong regionHandle;
475 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle)) 475 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
476 { 476 {
477 if (OnAgentLocation != null) 477 if (OnAgentLocation != null)
478 OnAgentLocation(agentID, regionID, regionHandle); 478 OnAgentLocation(agentID, regionID, regionHandle);
479 479
480 result["responsestring"] = "TRUE"; 480 result["responsestring"] = "TRUE";
481 } 481 }
482 482
483 XmlRpcResponse response = new XmlRpcResponse(); 483 XmlRpcResponse response = new XmlRpcResponse();
484 response.Value = result; 484 response.Value = result;
485 return response; 485 return response;
486 } 486 }
487 487
488 public XmlRpcResponse AgentLeaving(XmlRpcRequest request) 488 public XmlRpcResponse AgentLeaving(XmlRpcRequest request)
489 { 489 {
490 Hashtable requestData = (Hashtable)request.Params[0]; 490 Hashtable requestData = (Hashtable)request.Params[0];
491 Hashtable result = new Hashtable(); 491 Hashtable result = new Hashtable();
492 492
493 UUID agentID; 493 UUID agentID;
494 UUID regionID; 494 UUID regionID;
495 ulong regionHandle; 495 ulong regionHandle;
496 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle)) 496 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
497 { 497 {
498 if (OnAgentLeaving != null) 498 if (OnAgentLeaving != null)
499 OnAgentLeaving(agentID, regionID, regionHandle); 499 OnAgentLeaving(agentID, regionID, regionHandle);
500 500
501 result["responsestring"] = "TRUE"; 501 result["responsestring"] = "TRUE";
502 } 502 }
503 503
504 XmlRpcResponse response = new XmlRpcResponse(); 504 XmlRpcResponse response = new XmlRpcResponse();
505 response.Value = result; 505 response.Value = result;
506 return response; 506 return response;
507 } 507 }
508 } 508 }
509} 509}