aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs156
1 files changed, 144 insertions, 12 deletions
diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
index 1726ea2..2eb1618 100644
--- a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs
@@ -90,7 +90,8 @@ namespace OpenSim.Region.Environment.Modules.Framework
90 90
91 // Register fallback handler 91 // Register fallback handler
92 // Why does EQG Fail on region crossings! 92 // Why does EQG Fail on region crossings!
93 scene.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack); 93
94 //scene.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack);
94 95
95 scene.EventManager.OnNewClient += OnNewClient; 96 scene.EventManager.OnNewClient += OnNewClient;
96 scene.EventManager.OnClientClosed += ClientClosed; 97 scene.EventManager.OnClientClosed += ClientClosed;
@@ -109,7 +110,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
109 110
110 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) 111 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p)
111 { 112 {
112 enabledYN = startupConfig.GetBoolean("EventQueue", false); 113 enabledYN = startupConfig.GetBoolean("EventQueue", true);
113 } 114 }
114 115
115 public void PostInitialise() 116 public void PostInitialise()
@@ -166,6 +167,44 @@ namespace OpenSim.Region.Environment.Modules.Framework
166 private void ClientClosed(UUID AgentID) 167 private void ClientClosed(UUID AgentID)
167 { 168 {
168 queues.Remove(AgentID); 169 queues.Remove(AgentID);
170 List<UUID> removeitems = new List<UUID>();
171 lock (m_AvatarQueueUUIDMapping)
172 {
173 foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys)
174 {
175 if (ky == AgentID)
176 {
177 removeitems.Add(ky);
178 }
179 }
180
181 foreach (UUID ky in removeitems)
182 {
183 m_AvatarQueueUUIDMapping.Remove(ky);
184 m_scene.RemoveHTTPHandler("","/CAPS/EQG/" + ky.ToString() + "/");
185 }
186
187 }
188 UUID searchval = UUID.Zero;
189
190 removeitems.Clear();
191
192 lock (m_QueueUUIDAvatarMapping)
193 {
194 foreach (UUID ky in m_QueueUUIDAvatarMapping.Keys)
195 {
196 searchval = m_QueueUUIDAvatarMapping[ky];
197
198 if (searchval == AgentID)
199 {
200 removeitems.Add(ky);
201 }
202 }
203
204 foreach (UUID ky in removeitems)
205 m_QueueUUIDAvatarMapping.Remove(ky);
206
207 }
169 m_log.DebugFormat("[EVENTQUEUE]: Client {0} deregistered in region {1}.", AgentID, m_scene.RegionInfo.RegionName); 208 m_log.DebugFormat("[EVENTQUEUE]: Client {0} deregistered in region {1}.", AgentID, m_scene.RegionInfo.RegionName);
170 } 209 }
171 210
@@ -177,15 +216,15 @@ namespace OpenSim.Region.Environment.Modules.Framework
177 216
178 private void MakeChildAgent(ScenePresence avatar) 217 private void MakeChildAgent(ScenePresence avatar)
179 { 218 {
180 m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0} in region {1}.", avatar.UUID, m_scene.RegionInfo.RegionName); 219 //m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0} in region {1}.", avatar.UUID, m_scene.RegionInfo.RegionName);
181 lock (m_ids) 220 //lock (m_ids)
182 { 221 // {
183 if (m_ids.ContainsKey(avatar.UUID)) 222 //if (m_ids.ContainsKey(avatar.UUID))
184 { 223 //{
185 // close the event queue. 224 // close the event queue.
186 //m_ids[avatar.UUID] = -1; 225 //m_ids[avatar.UUID] = -1;
187 } 226 //}
188 } 227 //}
189 } 228 }
190 229
191 public void OnRegisterCaps(UUID agentID, Caps caps) 230 public void OnRegisterCaps(UUID agentID, Caps caps)
@@ -222,12 +261,18 @@ namespace OpenSim.Region.Environment.Modules.Framework
222 } 261 }
223 262
224 m_log.DebugFormat("[EVENTQUEUE]: CAPS URL: {0}", capsBase + EventQueueGetUUID.ToString() + "/"); 263 m_log.DebugFormat("[EVENTQUEUE]: CAPS URL: {0}", capsBase + EventQueueGetUUID.ToString() + "/");
264 // Register this as a caps handler
225 caps.RegisterHandler("EventQueueGet", 265 caps.RegisterHandler("EventQueueGet",
226 new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString(), 266 new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/",
227 delegate(Hashtable m_dhttpMethod) 267 delegate(Hashtable m_dhttpMethod)
228 { 268 {
229 return ProcessQueue(m_dhttpMethod,agentID, caps); 269 return ProcessQueue(m_dhttpMethod,agentID, caps);
230 })); 270 }));
271
272 bool boolval = false;
273 // This will persist this beyond the expiry of the caps handlers
274 boolval = m_scene.AddHTTPHandler(capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePath2);
275
231 Random rnd = new Random(System.Environment.TickCount); 276 Random rnd = new Random(System.Environment.TickCount);
232 lock (m_ids) 277 lock (m_ids)
233 { 278 {
@@ -262,6 +307,14 @@ namespace OpenSim.Region.Environment.Modules.Framework
262 307
263 if (element == null) 308 if (element == null)
264 { 309 {
310 if (thisID == -1) // close-request
311 {
312 responsedata["int_response_code"] = 404;
313 responsedata["content_type"] = "text/plain";
314 responsedata["keepalive"] = false;
315 responsedata["str_response_string"] = "";
316 return responsedata;
317 }
265 responsedata["int_response_code"] = 502; 318 responsedata["int_response_code"] = 502;
266 responsedata["content_type"] = "text/plain"; 319 responsedata["content_type"] = "text/plain";
267 responsedata["keepalive"] = false; 320 responsedata["keepalive"] = false;
@@ -272,6 +325,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
272 } 325 }
273 326
274 327
328
275 LLSDArray array = new LLSDArray(); 329 LLSDArray array = new LLSDArray();
276 if (element == null) // didn't have an event in 15s 330 if (element == null) // didn't have an event in 15s
277 { 331 {
@@ -306,6 +360,59 @@ namespace OpenSim.Region.Environment.Modules.Framework
306 360
307 return responsedata; 361 return responsedata;
308 } 362 }
363
364 public Hashtable EventQueuePath2(Hashtable request)
365 {
366 string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");
367 // pull off the last "/" in the path.
368 Hashtable responsedata = new Hashtable();
369 capuuid = capuuid.Substring(0, capuuid.Length - 1);
370 capuuid = capuuid.Replace("/CAPS/EQG/", "");
371 UUID AvatarID = UUID.Zero;
372 UUID capUUID = UUID.Zero;
373
374 // parse the path and search for the avatar with it registered
375 if (UUID.TryParse(capuuid, out capUUID))
376 {
377 lock (m_QueueUUIDAvatarMapping)
378 {
379 if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
380 {
381 AvatarID = m_QueueUUIDAvatarMapping[capUUID];
382 }
383 }
384 if (AvatarID != UUID.Zero)
385 {
386 // m_scene.GetCapsHandlerForUser will return null if the agent doesn't have a caps handler
387 // registered
388 return ProcessQueue(request, AvatarID, m_scene.GetCapsHandlerForUser(AvatarID));
389 }
390 else
391 {
392 responsedata["int_response_code"] = 404;
393 responsedata["content_type"] = "text/plain";
394 responsedata["keepalive"] = false;
395 responsedata["str_response_string"] = "Not Found";
396 responsedata["error_status_text"] = "Not Found";
397 responsedata["http_protocol_version"] = "HTTP/1.0";
398 return responsedata;
399 // return 404
400 }
401 }
402 else
403 {
404 responsedata["int_response_code"] = 404;
405 responsedata["content_type"] = "text/plain";
406 responsedata["keepalive"] = false;
407 responsedata["str_response_string"] = "Not Found";
408 responsedata["error_status_text"] = "Not Found";
409 responsedata["http_protocol_version"] = "HTTP/1.0";
410 return responsedata;
411 // return 404
412 }
413
414 }
415
309 public LLSD EventQueueFallBack(string path, LLSD request, string endpoint) 416 public LLSD EventQueueFallBack(string path, LLSD request, string endpoint)
310 { 417 {
311 // This is a fallback element to keep the client from loosing EventQueueGet 418 // This is a fallback element to keep the client from loosing EventQueueGet
@@ -318,7 +425,9 @@ namespace OpenSim.Region.Environment.Modules.Framework
318 UUID capUUID = UUID.Zero; 425 UUID capUUID = UUID.Zero;
319 if (UUID.TryParse(capuuid, out capUUID)) 426 if (UUID.TryParse(capuuid, out capUUID))
320 { 427 {
321 428/* Don't remove this yet code cleaners!
429 * Still testing this!
430 *
322 lock (m_QueueUUIDAvatarMapping) 431 lock (m_QueueUUIDAvatarMapping)
323 { 432 {
324 if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) 433 if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
@@ -326,8 +435,28 @@ namespace OpenSim.Region.Environment.Modules.Framework
326 AvatarID = m_QueueUUIDAvatarMapping[capUUID]; 435 AvatarID = m_QueueUUIDAvatarMapping[capUUID];
327 } 436 }
328 } 437 }
438
439
329 if (AvatarID != UUID.Zero) 440 if (AvatarID != UUID.Zero)
330 { 441 {
442 // Repair the CAP!
443 //OpenSim.Framework.Communications.Capabilities.Caps caps = m_scene.GetCapsHandlerForUser(AvatarID);
444 //string capsBase = "/CAPS/EQG/";
445 //caps.RegisterHandler("EventQueueGet",
446 //new RestHTTPHandler("POST", capsBase + capUUID.ToString() + "/",
447 //delegate(Hashtable m_dhttpMethod)
448 //{
449 // return ProcessQueue(m_dhttpMethod, AvatarID, caps);
450 //}));
451 // start new ID sequence.
452 Random rnd = new Random(System.Environment.TickCount);
453 lock (m_ids)
454 {
455 if (!m_ids.ContainsKey(AvatarID))
456 m_ids.Add(AvatarID, rnd.Next(30000000));
457 }
458
459
331 int thisID = 0; 460 int thisID = 0;
332 lock (m_ids) 461 lock (m_ids)
333 thisID = m_ids[AvatarID]; 462 thisID = m_ids[AvatarID];
@@ -365,11 +494,14 @@ namespace OpenSim.Region.Environment.Modules.Framework
365 { 494 {
366 return new LLSD(); 495 return new LLSD();
367 } 496 }
497*
498*/
368 } 499 }
369 else 500 else
370 { 501 {
371 return new LLSD(); 502 //return new LLSD();
372 } 503 }
504 return new LLSDString("shutdown404!");
373 } 505 }
374 } 506 }
375} 507}