EventQueueGetModule.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Threading;
  33. using log4net;
  34. using Nini.Config;
  35. using OpenMetaverse;
  36. using OpenMetaverse.Packets;
  37. using OpenMetaverse.StructuredData;
  38. using OpenSim.Framework;
  39. using OpenSim.Framework.Servers;
  40. using OpenSim.Framework.Servers.HttpServer;
  41. using OpenSim.Region.Framework.Interfaces;
  42. using OpenSim.Region.Framework.Scenes;
  43. using BlockingLLSDQueue = OpenSim.Framework.BlockingQueue<OpenMetaverse.StructuredData.OSD>;
  44. using Caps=OpenSim.Framework.Capabilities.Caps;
  45. namespace OpenSim.Region.CoreModules.Framework.EventQueue
  46. {
  47. public struct QueueItem
  48. {
  49. public int id;
  50. public OSDMap body;
  51. }
  52. public class EventQueueGetModule : IEventQueue, IRegionModule
  53. {
  54. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  55. protected Scene m_scene = null;
  56. private IConfigSource m_gConfig;
  57. bool enabledYN = false;
  58. private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>();
  59. private Dictionary<UUID, Queue<OSD>> queues = new Dictionary<UUID, Queue<OSD>>();
  60. private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>();
  61. private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>();
  62. #region IRegionModule methods
  63. public virtual void Initialise(Scene scene, IConfigSource config)
  64. {
  65. m_gConfig = config;
  66. IConfig startupConfig = m_gConfig.Configs["Startup"];
  67. ReadConfigAndPopulate(scene, startupConfig, "Startup");
  68. if (enabledYN)
  69. {
  70. m_scene = scene;
  71. scene.RegisterModuleInterface<IEventQueue>(this);
  72. // Register fallback handler
  73. // Why does EQG Fail on region crossings!
  74. //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack);
  75. scene.EventManager.OnNewClient += OnNewClient;
  76. // TODO: Leaving these open, or closing them when we
  77. // become a child is incorrect. It messes up TP in a big
  78. // way. CAPS/EQ need to be active as long as the UDP
  79. // circuit is there.
  80. scene.EventManager.OnClientClosed += ClientClosed;
  81. scene.EventManager.OnMakeChildAgent += MakeChildAgent;
  82. scene.EventManager.OnRegisterCaps += OnRegisterCaps;
  83. }
  84. else
  85. {
  86. m_gConfig = null;
  87. }
  88. }
  89. private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p)
  90. {
  91. enabledYN = startupConfig.GetBoolean("EventQueue", true);
  92. }
  93. public void PostInitialise()
  94. {
  95. }
  96. public virtual void Close()
  97. {
  98. }
  99. public virtual string Name
  100. {
  101. get { return "EventQueueGetModule"; }
  102. }
  103. public bool IsSharedModule
  104. {
  105. get { return false; }
  106. }
  107. #endregion
  108. /// <summary>
  109. /// Always returns a valid queue
  110. /// </summary>
  111. /// <param name="agentId"></param>
  112. /// <returns></returns>
  113. private Queue<OSD> TryGetQueue(UUID agentId)
  114. {
  115. lock (queues)
  116. {
  117. if (!queues.ContainsKey(agentId))
  118. {
  119. m_log.DebugFormat(
  120. "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}",
  121. agentId, m_scene.RegionInfo.RegionName);
  122. queues[agentId] = new Queue<OSD>();
  123. }
  124. return queues[agentId];
  125. }
  126. }
  127. /// <summary>
  128. /// May return a null queue
  129. /// </summary>
  130. /// <param name="agentId"></param>
  131. /// <returns></returns>
  132. private Queue<OSD> GetQueue(UUID agentId)
  133. {
  134. lock (queues)
  135. {
  136. if (queues.ContainsKey(agentId))
  137. {
  138. return queues[agentId];
  139. }
  140. else
  141. return null;
  142. }
  143. }
  144. #region IEventQueue Members
  145. public bool Enqueue(OSD ev, UUID avatarID)
  146. {
  147. //m_log.DebugFormat("[EVENTQUEUE]: Enqueuing event for {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName);
  148. try
  149. {
  150. Queue<OSD> queue = GetQueue(avatarID);
  151. if (queue != null)
  152. queue.Enqueue(ev);
  153. }
  154. catch(NullReferenceException e)
  155. {
  156. m_log.Error("[EVENTQUEUE] Caught exception: " + e);
  157. return false;
  158. }
  159. return true;
  160. }
  161. #endregion
  162. private void OnNewClient(IClientAPI client)
  163. {
  164. //client.OnLogout += ClientClosed;
  165. }
  166. // private void ClientClosed(IClientAPI client)
  167. // {
  168. // ClientClosed(client.AgentId);
  169. // }
  170. private void ClientClosed(UUID AgentID, Scene scene)
  171. {
  172. m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", AgentID, m_scene.RegionInfo.RegionName);
  173. int count = 0;
  174. while (queues.ContainsKey(AgentID) && queues[AgentID].Count > 0 && count++ < 5)
  175. {
  176. Thread.Sleep(1000);
  177. }
  178. lock (queues)
  179. {
  180. queues.Remove(AgentID);
  181. }
  182. List<UUID> removeitems = new List<UUID>();
  183. lock (m_AvatarQueueUUIDMapping)
  184. {
  185. foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys)
  186. {
  187. if (ky == AgentID)
  188. {
  189. removeitems.Add(ky);
  190. }
  191. }
  192. foreach (UUID ky in removeitems)
  193. {
  194. m_AvatarQueueUUIDMapping.Remove(ky);
  195. MainServer.Instance.RemovePollServiceHTTPHandler("","/CAPS/EQG/" + ky.ToString() + "/");
  196. }
  197. }
  198. UUID searchval = UUID.Zero;
  199. removeitems.Clear();
  200. lock (m_QueueUUIDAvatarMapping)
  201. {
  202. foreach (UUID ky in m_QueueUUIDAvatarMapping.Keys)
  203. {
  204. searchval = m_QueueUUIDAvatarMapping[ky];
  205. if (searchval == AgentID)
  206. {
  207. removeitems.Add(ky);
  208. }
  209. }
  210. foreach (UUID ky in removeitems)
  211. m_QueueUUIDAvatarMapping.Remove(ky);
  212. }
  213. }
  214. private void MakeChildAgent(ScenePresence avatar)
  215. {
  216. //m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0} in region {1}.", avatar.UUID, m_scene.RegionInfo.RegionName);
  217. //lock (m_ids)
  218. // {
  219. //if (m_ids.ContainsKey(avatar.UUID))
  220. //{
  221. // close the event queue.
  222. //m_ids[avatar.UUID] = -1;
  223. //}
  224. //}
  225. }
  226. public void OnRegisterCaps(UUID agentID, Caps caps)
  227. {
  228. // Register an event queue for the client
  229. //m_log.DebugFormat(
  230. // "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
  231. // agentID, caps, m_scene.RegionInfo.RegionName);
  232. // Let's instantiate a Queue for this agent right now
  233. TryGetQueue(agentID);
  234. string capsBase = "/CAPS/EQG/";
  235. UUID EventQueueGetUUID = UUID.Zero;
  236. lock (m_AvatarQueueUUIDMapping)
  237. {
  238. // Reuse open queues. The client does!
  239. if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
  240. {
  241. m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
  242. EventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
  243. }
  244. else
  245. {
  246. EventQueueGetUUID = UUID.Random();
  247. //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
  248. }
  249. }
  250. lock (m_QueueUUIDAvatarMapping)
  251. {
  252. if (!m_QueueUUIDAvatarMapping.ContainsKey(EventQueueGetUUID))
  253. m_QueueUUIDAvatarMapping.Add(EventQueueGetUUID, agentID);
  254. }
  255. lock (m_AvatarQueueUUIDMapping)
  256. {
  257. if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID))
  258. m_AvatarQueueUUIDMapping.Add(agentID, EventQueueGetUUID);
  259. }
  260. // Register this as a caps handler
  261. caps.RegisterHandler("EventQueueGet",
  262. new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/",
  263. delegate(Hashtable m_dhttpMethod)
  264. {
  265. return ProcessQueue(m_dhttpMethod, agentID, caps);
  266. }));
  267. // This will persist this beyond the expiry of the caps handlers
  268. MainServer.Instance.AddPollServiceHTTPHandler(
  269. capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
  270. Random rnd = new Random(Environment.TickCount);
  271. lock (m_ids)
  272. {
  273. if (!m_ids.ContainsKey(agentID))
  274. m_ids.Add(agentID, rnd.Next(30000000));
  275. }
  276. }
  277. public bool HasEvents(UUID requestID, UUID agentID)
  278. {
  279. // Don't use this, because of race conditions at agent closing time
  280. //Queue<OSD> queue = TryGetQueue(agentID);
  281. Queue<OSD> queue = GetQueue(agentID);
  282. if (queue != null)
  283. lock (queue)
  284. {
  285. if (queue.Count > 0)
  286. return true;
  287. else
  288. return false;
  289. }
  290. return false;
  291. }
  292. public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request)
  293. {
  294. Queue<OSD> queue = TryGetQueue(pAgentId);
  295. OSD element;
  296. lock (queue)
  297. {
  298. if (queue.Count == 0)
  299. return NoEvents(requestID, pAgentId);
  300. element = queue.Dequeue(); // 15s timeout
  301. }
  302. int thisID = 0;
  303. lock (m_ids)
  304. thisID = m_ids[pAgentId];
  305. OSDArray array = new OSDArray();
  306. if (element == null) // didn't have an event in 15s
  307. {
  308. // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
  309. array.Add(EventQueueHelper.KeepAliveEvent());
  310. m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName);
  311. }
  312. else
  313. {
  314. array.Add(element);
  315. lock (queue)
  316. {
  317. while (queue.Count > 0)
  318. {
  319. array.Add(queue.Dequeue());
  320. thisID++;
  321. }
  322. }
  323. }
  324. OSDMap events = new OSDMap();
  325. events.Add("events", array);
  326. events.Add("id", new OSDInteger(thisID));
  327. lock (m_ids)
  328. {
  329. m_ids[pAgentId] = thisID + 1;
  330. }
  331. Hashtable responsedata = new Hashtable();
  332. responsedata["int_response_code"] = 200;
  333. responsedata["content_type"] = "application/xml";
  334. responsedata["keepalive"] = false;
  335. responsedata["reusecontext"] = false;
  336. responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
  337. return responsedata;
  338. //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
  339. }
  340. public Hashtable NoEvents(UUID requestID, UUID agentID)
  341. {
  342. Hashtable responsedata = new Hashtable();
  343. responsedata["int_response_code"] = 502;
  344. responsedata["content_type"] = "text/plain";
  345. responsedata["keepalive"] = false;
  346. responsedata["reusecontext"] = false;
  347. responsedata["str_response_string"] = "Upstream error: ";
  348. responsedata["error_status_text"] = "Upstream error:";
  349. responsedata["http_protocol_version"] = "HTTP/1.0";
  350. return responsedata;
  351. }
  352. public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps)
  353. {
  354. // TODO: this has to be redone to not busy-wait (and block the thread),
  355. // TODO: as soon as we have a non-blocking way to handle HTTP-requests.
  356. // if (m_log.IsDebugEnabled)
  357. // {
  358. // String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ ";
  359. // foreach (object key in request.Keys)
  360. // {
  361. // debug += key.ToString() + "=" + request[key].ToString() + " ";
  362. // }
  363. // m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
  364. // }
  365. Queue<OSD> queue = TryGetQueue(agentID);
  366. OSD element = queue.Dequeue(); // 15s timeout
  367. Hashtable responsedata = new Hashtable();
  368. int thisID = 0;
  369. lock (m_ids)
  370. thisID = m_ids[agentID];
  371. if (element == null)
  372. {
  373. //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName);
  374. if (thisID == -1) // close-request
  375. {
  376. m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName);
  377. responsedata["int_response_code"] = 404; //501; //410; //404;
  378. responsedata["content_type"] = "text/plain";
  379. responsedata["keepalive"] = false;
  380. responsedata["str_response_string"] = "Closed EQG";
  381. return responsedata;
  382. }
  383. responsedata["int_response_code"] = 502;
  384. responsedata["content_type"] = "text/plain";
  385. responsedata["keepalive"] = false;
  386. responsedata["str_response_string"] = "Upstream error: ";
  387. responsedata["error_status_text"] = "Upstream error:";
  388. responsedata["http_protocol_version"] = "HTTP/1.0";
  389. return responsedata;
  390. }
  391. OSDArray array = new OSDArray();
  392. if (element == null) // didn't have an event in 15s
  393. {
  394. // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
  395. array.Add(EventQueueHelper.KeepAliveEvent());
  396. m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName);
  397. }
  398. else
  399. {
  400. array.Add(element);
  401. while (queue.Count > 0)
  402. {
  403. array.Add(queue.Dequeue());
  404. thisID++;
  405. }
  406. }
  407. OSDMap events = new OSDMap();
  408. events.Add("events", array);
  409. events.Add("id", new OSDInteger(thisID));
  410. lock (m_ids)
  411. {
  412. m_ids[agentID] = thisID + 1;
  413. }
  414. responsedata["int_response_code"] = 200;
  415. responsedata["content_type"] = "application/xml";
  416. responsedata["keepalive"] = false;
  417. responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
  418. //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
  419. return responsedata;
  420. }
  421. public Hashtable EventQueuePoll(Hashtable request)
  422. {
  423. return new Hashtable();
  424. }
  425. public Hashtable EventQueuePath2(Hashtable request)
  426. {
  427. string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");
  428. // pull off the last "/" in the path.
  429. Hashtable responsedata = new Hashtable();
  430. capuuid = capuuid.Substring(0, capuuid.Length - 1);
  431. capuuid = capuuid.Replace("/CAPS/EQG/", "");
  432. UUID AvatarID = UUID.Zero;
  433. UUID capUUID = UUID.Zero;
  434. // parse the path and search for the avatar with it registered
  435. if (UUID.TryParse(capuuid, out capUUID))
  436. {
  437. lock (m_QueueUUIDAvatarMapping)
  438. {
  439. if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
  440. {
  441. AvatarID = m_QueueUUIDAvatarMapping[capUUID];
  442. }
  443. }
  444. if (AvatarID != UUID.Zero)
  445. {
  446. return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID));
  447. }
  448. else
  449. {
  450. responsedata["int_response_code"] = 404;
  451. responsedata["content_type"] = "text/plain";
  452. responsedata["keepalive"] = false;
  453. responsedata["str_response_string"] = "Not Found";
  454. responsedata["error_status_text"] = "Not Found";
  455. responsedata["http_protocol_version"] = "HTTP/1.0";
  456. return responsedata;
  457. // return 404
  458. }
  459. }
  460. else
  461. {
  462. responsedata["int_response_code"] = 404;
  463. responsedata["content_type"] = "text/plain";
  464. responsedata["keepalive"] = false;
  465. responsedata["str_response_string"] = "Not Found";
  466. responsedata["error_status_text"] = "Not Found";
  467. responsedata["http_protocol_version"] = "HTTP/1.0";
  468. return responsedata;
  469. // return 404
  470. }
  471. }
  472. public OSD EventQueueFallBack(string path, OSD request, string endpoint)
  473. {
  474. // This is a fallback element to keep the client from loosing EventQueueGet
  475. // Why does CAPS fail sometimes!?
  476. m_log.Warn("[EVENTQUEUE]: In the Fallback handler! We lost the Queue in the rest handler!");
  477. string capuuid = path.Replace("/CAPS/EQG/","");
  478. capuuid = capuuid.Substring(0, capuuid.Length - 1);
  479. // UUID AvatarID = UUID.Zero;
  480. UUID capUUID = UUID.Zero;
  481. if (UUID.TryParse(capuuid, out capUUID))
  482. {
  483. /* Don't remove this yet code cleaners!
  484. * Still testing this!
  485. *
  486. lock (m_QueueUUIDAvatarMapping)
  487. {
  488. if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID))
  489. {
  490. AvatarID = m_QueueUUIDAvatarMapping[capUUID];
  491. }
  492. }
  493. if (AvatarID != UUID.Zero)
  494. {
  495. // Repair the CAP!
  496. //OpenSim.Framework.Capabilities.Caps caps = m_scene.GetCapsHandlerForUser(AvatarID);
  497. //string capsBase = "/CAPS/EQG/";
  498. //caps.RegisterHandler("EventQueueGet",
  499. //new RestHTTPHandler("POST", capsBase + capUUID.ToString() + "/",
  500. //delegate(Hashtable m_dhttpMethod)
  501. //{
  502. // return ProcessQueue(m_dhttpMethod, AvatarID, caps);
  503. //}));
  504. // start new ID sequence.
  505. Random rnd = new Random(System.Environment.TickCount);
  506. lock (m_ids)
  507. {
  508. if (!m_ids.ContainsKey(AvatarID))
  509. m_ids.Add(AvatarID, rnd.Next(30000000));
  510. }
  511. int thisID = 0;
  512. lock (m_ids)
  513. thisID = m_ids[AvatarID];
  514. BlockingLLSDQueue queue = GetQueue(AvatarID);
  515. OSDArray array = new OSDArray();
  516. LLSD element = queue.Dequeue(15000); // 15s timeout
  517. if (element == null)
  518. {
  519. array.Add(EventQueueHelper.KeepAliveEvent());
  520. }
  521. else
  522. {
  523. array.Add(element);
  524. while (queue.Count() > 0)
  525. {
  526. array.Add(queue.Dequeue(1));
  527. thisID++;
  528. }
  529. }
  530. OSDMap events = new OSDMap();
  531. events.Add("events", array);
  532. events.Add("id", new LLSDInteger(thisID));
  533. lock (m_ids)
  534. {
  535. m_ids[AvatarID] = thisID + 1;
  536. }
  537. return events;
  538. }
  539. else
  540. {
  541. return new LLSD();
  542. }
  543. *
  544. */
  545. }
  546. else
  547. {
  548. //return new LLSD();
  549. }
  550. return new OSDString("shutdown404!");
  551. }
  552. public void DisableSimulator(ulong handle, UUID avatarID)
  553. {
  554. OSD item = EventQueueHelper.DisableSimulator(handle);
  555. Enqueue(item, avatarID);
  556. }
  557. public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID)
  558. {
  559. OSD item = EventQueueHelper.EnableSimulator(handle, endPoint);
  560. Enqueue(item, avatarID);
  561. }
  562. public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath)
  563. {
  564. OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath);
  565. Enqueue(item, avatarID);
  566. }
  567. public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess,
  568. IPEndPoint regionExternalEndPoint,
  569. uint locationID, uint flags, string capsURL,
  570. UUID avatarID)
  571. {
  572. OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint,
  573. locationID, flags, capsURL, avatarID);
  574. Enqueue(item, avatarID);
  575. }
  576. public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
  577. IPEndPoint newRegionExternalEndPoint,
  578. string capsURL, UUID avatarID, UUID sessionID)
  579. {
  580. OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint,
  581. capsURL, avatarID, sessionID);
  582. Enqueue(item, avatarID);
  583. }
  584. public void ChatterboxInvitation(UUID sessionID, string sessionName,
  585. UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog,
  586. uint timeStamp, bool offline, int parentEstateID, Vector3 position,
  587. uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
  588. {
  589. OSD item = EventQueueHelper.ChatterboxInvitation(sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
  590. timeStamp, offline, parentEstateID, position, ttl, transactionID,
  591. fromGroup, binaryBucket);
  592. Enqueue(item, toAgent);
  593. //m_log.InfoFormat("########### eq ChatterboxInvitation #############\n{0}", item);
  594. }
  595. public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat,
  596. bool isModerator, bool textMute)
  597. {
  598. OSD item = EventQueueHelper.ChatterBoxSessionAgentListUpdates(sessionID, fromAgent, canVoiceChat,
  599. isModerator, textMute);
  600. Enqueue(item, toAgent);
  601. //m_log.InfoFormat("########### eq ChatterBoxSessionAgentListUpdates #############\n{0}", item);
  602. }
  603. public void ParcelProperties(ParcelPropertiesPacket parcelPropertiesPacket, UUID avatarID)
  604. {
  605. OSD item = EventQueueHelper.ParcelProperties(parcelPropertiesPacket);
  606. Enqueue(item, avatarID);
  607. }
  608. public void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
  609. {
  610. OSD item = EventQueueHelper.GroupMembership(groupUpdate);
  611. Enqueue(item, avatarID);
  612. }
  613. public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID)
  614. {
  615. OSD item = EventQueueHelper.PlacesQuery(groupUpdate);
  616. Enqueue(item, avatarID);
  617. }
  618. }
  619. }