1
0

EventQueueGetModule.cs 27 KB

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