WorldCommModule.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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 OpenSim 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 OpenMetaverse;
  31. using Nini.Config;
  32. using OpenSim.Framework;
  33. using OpenSim.Region.Environment.Interfaces;
  34. using OpenSim.Region.Environment.Scenes;
  35. // using log4net;
  36. // using System.Reflection;
  37. /*****************************************************
  38. *
  39. * WorldCommModule
  40. *
  41. *
  42. * Holding place for world comms - basically llListen
  43. * function implementation.
  44. *
  45. * lLListen(integer channel, string name, key id, string msg)
  46. * The name, id, and msg arguments specify the filtering
  47. * criteria. You can pass the empty string
  48. * (or NULL_KEY for id) for these to set a completely
  49. * open filter; this causes the listen() event handler to be
  50. * invoked for all chat on the channel. To listen only
  51. * for chat spoken by a specific object or avatar,
  52. * specify the name and/or id arguments. To listen
  53. * only for a specific command, specify the
  54. * (case-sensitive) msg argument. If msg is not empty,
  55. * listener will only hear strings which are exactly equal
  56. * to msg. You can also use all the arguments to establish
  57. * the most restrictive filtering criteria.
  58. *
  59. * It might be useful for each listener to maintain a message
  60. * digest, with a list of recent messages by UUID. This can
  61. * be used to prevent in-world repeater loops. However, the
  62. * linden functions do not have this capability, so for now
  63. * thats the way it works.
  64. * Instead it blocks messages originating from the same prim.
  65. * (not Object!)
  66. *
  67. * For LSL compliance, note the following:
  68. * (Tested again 1.21.1 on May 2, 2008)
  69. * 1. 'id' has to be parsed into a UUID. None-UUID keys are
  70. * to be replaced by the ZeroID key. (Well, TryParse does
  71. * that for us.
  72. * 2. Setting up an listen event from the same script, with the
  73. * same filter settings (including step 1), returns the same
  74. * handle as the original filter.
  75. * 3. (TODO) handles should be script-local. Starting from 1.
  76. * Might be actually easier to map the global handle into
  77. * script-local handle in the ScriptEngine. Not sure if its
  78. * worth the effort tho.
  79. *
  80. * **************************************************/
  81. namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
  82. {
  83. public class WorldCommModule : IRegionModule, IWorldComm
  84. {
  85. // private static readonly ILog m_log =
  86. // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  87. private ListenerManager m_listenerManager;
  88. private Queue m_pending;
  89. private Queue m_pendingQ;
  90. private Scene m_scene;
  91. private int m_whisperdistance = 10;
  92. private int m_saydistance = 30;
  93. private int m_shoutdistance = 100;
  94. #region IRegionModule Members
  95. public void Initialise(Scene scene, IConfigSource config)
  96. {
  97. // wrap this in a try block so that defaults will work if
  98. // the config file doesn't specify otherwise.
  99. int maxlisteners = 1000;
  100. int maxhandles = 64;
  101. try
  102. {
  103. m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
  104. m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
  105. m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
  106. maxlisteners = config.Configs["Chat"].GetInt("max_listens_per_region", maxlisteners);
  107. maxhandles = config.Configs["Chat"].GetInt("max_listens_per_script", maxhandles);
  108. }
  109. catch (Exception)
  110. {
  111. }
  112. if (maxlisteners < 1) maxlisteners = int.MaxValue;
  113. if (maxhandles < 1) maxhandles = int.MaxValue;
  114. m_scene = scene;
  115. m_scene.RegisterModuleInterface<IWorldComm>(this);
  116. m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
  117. m_scene.EventManager.OnChatFromClient += DeliverClientMessage;
  118. m_scene.EventManager.OnChatBroadcast += DeliverClientMessage;
  119. m_pendingQ = new Queue();
  120. m_pending = Queue.Synchronized(m_pendingQ);
  121. }
  122. public void PostInitialise()
  123. {
  124. }
  125. public void Close()
  126. {
  127. }
  128. public string Name
  129. {
  130. get { return "WorldCommModule"; }
  131. }
  132. public bool IsSharedModule
  133. {
  134. get { return false; }
  135. }
  136. #endregion
  137. #region IWorldComm Members
  138. /// <summary>
  139. /// Create a listen event callback with the specified filters.
  140. /// The parameters localID,itemID are needed to uniquely identify
  141. /// the script during 'peek' time. Parameter hostID is needed to
  142. /// determine the position of the script.
  143. /// </summary>
  144. /// <param name="localID">localID of the script engine</param>
  145. /// <param name="itemID">UUID of the script engine</param>
  146. /// <param name="hostID">UUID of the SceneObjectPart</param>
  147. /// <param name="channel">channel to listen on</param>
  148. /// <param name="name">name to filter on</param>
  149. /// <param name="id">key to filter on (user given, could be totally faked)</param>
  150. /// <param name="msg">msg to filter on</param>
  151. /// <returns>number of the scripts handle</returns>
  152. public int Listen(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg)
  153. {
  154. return m_listenerManager.AddListener(localID, itemID, hostID, channel, name, id, msg);
  155. }
  156. /// <summary>
  157. /// Sets the listen event with handle as active (active = TRUE) or inactive (active = FALSE).
  158. /// The handle used is returned from Listen()
  159. /// </summary>
  160. /// <param name="itemID">UUID of the script engine</param>
  161. /// <param name="handle">handle returned by Listen()</param>
  162. /// <param name="active">temp. activate or deactivate the Listen()</param>
  163. public void ListenControl(UUID itemID, int handle, int active)
  164. {
  165. if (active == 1)
  166. m_listenerManager.Activate(itemID, handle);
  167. else if (active == 0)
  168. m_listenerManager.Dectivate(itemID, handle);
  169. }
  170. /// <summary>
  171. /// Removes the listen event callback with handle
  172. /// </summary>
  173. /// <param name="itemID">UUID of the script engine</param>
  174. /// <param name="handle">handle returned by Listen()</param>
  175. public void ListenRemove(UUID itemID, int handle)
  176. {
  177. m_listenerManager.Remove(itemID, handle);
  178. }
  179. /// <summary>
  180. /// Removes all listen event callbacks for the given itemID
  181. /// (script engine)
  182. /// </summary>
  183. /// <param name="itemID">UUID of the script engine</param>
  184. public void DeleteListener(UUID itemID)
  185. {
  186. m_listenerManager.DeleteListener(itemID);
  187. }
  188. protected static Vector3 CenterOfRegion = new Vector3(128, 128, 20);
  189. public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg)
  190. {
  191. Vector3 position;
  192. SceneObjectPart source;
  193. ScenePresence avatar;
  194. if ((source = m_scene.GetSceneObjectPart(id)) != null)
  195. position = source.AbsolutePosition;
  196. else if ((avatar = m_scene.GetScenePresence(id)) != null)
  197. position = avatar.AbsolutePosition;
  198. else if (ChatTypeEnum.Region == type)
  199. position = CenterOfRegion;
  200. else
  201. return;
  202. DeliverMessage(type, channel, name, id, msg, position);
  203. }
  204. /// <summary>
  205. /// This method scans over the objects which registered an interest in listen callbacks.
  206. /// For everyone it finds, it checks if it fits the given filter. If it does, then
  207. /// enqueue the message for delivery to the objects listen event handler.
  208. /// The enqueued ListenerInfo no longer has filter values, but the actually trigged values.
  209. /// Objects that do an llSay have their messages delivered here and for nearby avatars,
  210. /// the OnChatFromClient event is used.
  211. /// </summary>
  212. /// <param name="type">type of delvery (whisper,say,shout or regionwide)</param>
  213. /// <param name="channel">channel to sent on</param>
  214. /// <param name="name">name of sender (object or avatar)</param>
  215. /// <param name="id">key of sender (object or avatar)</param>
  216. /// <param name="msg">msg to sent</param>
  217. public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position)
  218. {
  219. // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}",
  220. // type, channel, name, id, msg);
  221. // Determine which listen event filters match the given set of arguments, this results
  222. // in a limited set of listeners, each belonging a host. If the host is in range, add them
  223. // to the pending queue.
  224. foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
  225. {
  226. // Dont process if this message is from yourself!
  227. if (li.GetHostID().Equals(id))
  228. continue;
  229. SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID());
  230. if (sPart == null)
  231. continue;
  232. double dis = Util.GetDistanceTo(sPart.AbsolutePosition, position);
  233. switch (type)
  234. {
  235. case ChatTypeEnum.Whisper:
  236. if (dis < m_whisperdistance)
  237. {
  238. lock (m_pending.SyncRoot)
  239. {
  240. m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
  241. }
  242. }
  243. break;
  244. case ChatTypeEnum.Say:
  245. if (dis < m_saydistance)
  246. {
  247. lock (m_pending.SyncRoot)
  248. {
  249. m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
  250. }
  251. }
  252. break;
  253. case ChatTypeEnum.Shout:
  254. if (dis < m_shoutdistance)
  255. {
  256. lock (m_pending.SyncRoot)
  257. {
  258. m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
  259. }
  260. }
  261. break;
  262. case ChatTypeEnum.Region:
  263. lock (m_pending.SyncRoot)
  264. {
  265. m_pending.Enqueue(new ListenerInfo(li,name,id,msg));
  266. }
  267. break;
  268. }
  269. }
  270. }
  271. /// <summary>
  272. /// Are there any listen events ready to be dispatched?
  273. /// </summary>
  274. /// <returns>boolean indication</returns>
  275. public bool HasMessages()
  276. {
  277. return (m_pending.Count > 0);
  278. }
  279. /// <summary>
  280. /// Pop the first availlable listen event from the queue
  281. /// </summary>
  282. /// <returns>ListenerInfo with filter filled in</returns>
  283. public ListenerInfo GetNextMessage()
  284. {
  285. ListenerInfo li = null;
  286. lock (m_pending.SyncRoot)
  287. {
  288. li = (ListenerInfo) m_pending.Dequeue();
  289. }
  290. return li;
  291. }
  292. #endregion
  293. /********************************************************************
  294. *
  295. * Listener Stuff
  296. *
  297. * *****************************************************************/
  298. private void DeliverClientMessage(Object sender, OSChatMessage e)
  299. {
  300. if (null != e.Sender)
  301. DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position);
  302. else
  303. DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position);
  304. }
  305. public Object[] GetSerializationData(UUID itemID)
  306. {
  307. return m_listenerManager.GetSerializationData(itemID);
  308. }
  309. public void CreateFromData(uint localID, UUID itemID, UUID hostID,
  310. Object[] data)
  311. {
  312. m_listenerManager.AddFromData(localID, itemID, hostID, data);
  313. }
  314. }
  315. public class ListenerManager
  316. {
  317. private Dictionary<int, List<ListenerInfo>> m_listeners = new Dictionary<int, List<ListenerInfo>>();
  318. private int m_maxlisteners;
  319. private int m_maxhandles;
  320. private int m_curlisteners;
  321. public ListenerManager(int maxlisteners, int maxhandles)
  322. {
  323. m_maxlisteners = maxlisteners;
  324. m_maxhandles = maxhandles;
  325. m_curlisteners = 0;
  326. }
  327. public int AddListener(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg)
  328. {
  329. // do we already have a match on this particular filter event?
  330. List<ListenerInfo> coll = GetListeners(itemID, channel, name, id, msg);
  331. if (coll.Count > 0)
  332. {
  333. // special case, called with same filter settings, return same handle
  334. // (2008-05-02, tested on 1.21.1 server, still holds)
  335. return coll[0].GetHandle();
  336. }
  337. if (m_curlisteners < m_maxlisteners)
  338. {
  339. int newHandle = GetNewHandle(itemID);
  340. if (newHandle > 0)
  341. {
  342. ListenerInfo li = new ListenerInfo(newHandle, localID, itemID, hostID, channel, name, id, msg);
  343. lock (m_listeners)
  344. {
  345. List<ListenerInfo> listeners;
  346. if (!m_listeners.TryGetValue(channel,out listeners))
  347. {
  348. listeners = new List<ListenerInfo>();
  349. m_listeners.Add(channel, listeners);
  350. }
  351. listeners.Add(li);
  352. m_curlisteners++;
  353. }
  354. return newHandle;
  355. }
  356. }
  357. return -1;
  358. }
  359. public void Remove(UUID itemID, int handle)
  360. {
  361. lock (m_listeners)
  362. {
  363. foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners)
  364. {
  365. foreach (ListenerInfo li in lis.Value)
  366. {
  367. if (li.GetItemID().Equals(itemID) && li.GetHandle().Equals(handle))
  368. {
  369. lis.Value.Remove(li);
  370. if (lis.Value.Count == 0)
  371. {
  372. m_listeners.Remove(lis.Key);
  373. m_curlisteners--;
  374. }
  375. // there should be only one, so we bail out early
  376. return;
  377. }
  378. }
  379. }
  380. }
  381. }
  382. public void DeleteListener(UUID itemID)
  383. {
  384. List<int> emptyChannels = new List<int>();
  385. List<ListenerInfo> removedListeners = new List<ListenerInfo>();
  386. lock (m_listeners)
  387. {
  388. foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners)
  389. {
  390. foreach (ListenerInfo li in lis.Value)
  391. {
  392. if (li.GetItemID().Equals(itemID))
  393. {
  394. // store them first, else the enumerated bails on us
  395. removedListeners.Add(li);
  396. }
  397. }
  398. foreach (ListenerInfo li in removedListeners)
  399. {
  400. lis.Value.Remove(li);
  401. m_curlisteners--;
  402. }
  403. removedListeners.Clear();
  404. if (lis.Value.Count == 0)
  405. {
  406. // again, store first, remove later
  407. emptyChannels.Add(lis.Key);
  408. }
  409. }
  410. foreach (int channel in emptyChannels)
  411. {
  412. m_listeners.Remove(channel);
  413. }
  414. }
  415. }
  416. public void Activate(UUID itemID, int handle)
  417. {
  418. lock (m_listeners)
  419. {
  420. foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners)
  421. {
  422. foreach (ListenerInfo li in lis.Value)
  423. {
  424. if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle)
  425. {
  426. li.Activate();
  427. // only one, bail out
  428. return;
  429. }
  430. }
  431. }
  432. }
  433. }
  434. public void Dectivate(UUID itemID, int handle)
  435. {
  436. lock (m_listeners)
  437. {
  438. foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners)
  439. {
  440. foreach (ListenerInfo li in lis.Value)
  441. {
  442. if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle)
  443. {
  444. li.Deactivate();
  445. // only one, bail out
  446. return;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. // non-locked access, since its always called in the context of the lock
  453. private int GetNewHandle(UUID itemID)
  454. {
  455. List<int> handles = new List<int>();
  456. // build a list of used keys for this specific itemID...
  457. foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners)
  458. {
  459. foreach (ListenerInfo li in lis.Value)
  460. {
  461. if (li.GetItemID().Equals(itemID))
  462. handles.Add(li.GetHandle());
  463. }
  464. }
  465. // Note: 0 is NOT a valid handle for llListen() to return
  466. for (int i = 1; i <= m_maxhandles; i++)
  467. {
  468. if (!handles.Contains(i))
  469. return i;
  470. }
  471. return -1;
  472. }
  473. // Theres probably a more clever and efficient way to
  474. // do this, maybe with regex.
  475. // PM2008: Ha, one could even be smart and define a specialized Enumerator.
  476. public List<ListenerInfo> GetListeners(UUID itemID, int channel, string name, UUID id, string msg)
  477. {
  478. List<ListenerInfo> collection = new List<ListenerInfo>();
  479. lock (m_listeners)
  480. {
  481. List<ListenerInfo> listeners;
  482. if (!m_listeners.TryGetValue(channel,out listeners))
  483. {
  484. return collection;
  485. }
  486. foreach (ListenerInfo li in listeners)
  487. {
  488. if (!li.IsActive())
  489. {
  490. continue;
  491. }
  492. if (!itemID.Equals(UUID.Zero) && !li.GetItemID().Equals(itemID))
  493. {
  494. continue;
  495. }
  496. if (li.GetName().Length > 0 && !li.GetName().Equals(name))
  497. {
  498. continue;
  499. }
  500. if (!li.GetID().Equals(UUID.Zero) && !li.GetID().Equals(id))
  501. {
  502. continue;
  503. }
  504. if (li.GetMessage().Length > 0 && !li.GetMessage().Equals(msg))
  505. {
  506. continue;
  507. }
  508. collection.Add(li);
  509. }
  510. }
  511. return collection;
  512. }
  513. public Object[] GetSerializationData(UUID itemID)
  514. {
  515. List<Object> data = new List<Object>();
  516. foreach (List<ListenerInfo> list in m_listeners.Values)
  517. {
  518. foreach (ListenerInfo l in list)
  519. {
  520. if (l.GetItemID() == itemID)
  521. data.AddRange(l.GetSerializationData());
  522. }
  523. }
  524. return (Object[])data.ToArray();
  525. }
  526. public void AddFromData(uint localID, UUID itemID, UUID hostID,
  527. Object[] data)
  528. {
  529. int idx = 0;
  530. Object[] item = new Object[6];
  531. while (idx < data.Length)
  532. {
  533. Array.Copy(data, idx, item, 0, 6);
  534. ListenerInfo info =
  535. ListenerInfo.FromData(localID, itemID, hostID, item);
  536. if (!m_listeners.ContainsKey((int)item[2]))
  537. m_listeners.Add((int)item[2], new List<ListenerInfo>());
  538. m_listeners[(int)item[2]].Add(info);
  539. idx+=6;
  540. }
  541. }
  542. }
  543. public class ListenerInfo
  544. {
  545. private bool m_active; // Listener is active or not
  546. private int m_handle; // Assigned handle of this listener
  547. private uint m_localID; // Local ID from script engine
  548. private UUID m_itemID; // ID of the host script engine
  549. private UUID m_hostID; // ID of the host/scene part
  550. private int m_channel; // Channel
  551. private UUID m_id; // ID to filter messages from
  552. private string m_name; // Object name to filter messages from
  553. private string m_message; // The message
  554. public ListenerInfo(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message)
  555. {
  556. Initialise(handle, localID, ItemID, hostID, channel, name, id, message);
  557. }
  558. public ListenerInfo(ListenerInfo li, string name, UUID id, string message)
  559. {
  560. Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message);
  561. }
  562. private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name,
  563. UUID id, string message)
  564. {
  565. m_active = true;
  566. m_handle = handle;
  567. m_localID = localID;
  568. m_itemID = ItemID;
  569. m_hostID = hostID;
  570. m_channel = channel;
  571. m_name = name;
  572. m_id = id;
  573. m_message = message;
  574. }
  575. public Object[] GetSerializationData()
  576. {
  577. Object[] data = new Object[6];
  578. data[0] = m_active;
  579. data[1] = m_handle;
  580. data[2] = m_channel;
  581. data[3] = m_name;
  582. data[4] = m_id;
  583. data[5] = m_message;
  584. return data;
  585. }
  586. public static ListenerInfo FromData(uint localID, UUID ItemID, UUID hostID, Object[] data)
  587. {
  588. ListenerInfo linfo = new ListenerInfo((int)data[1], localID,
  589. ItemID, hostID, (int)data[2], (string)data[3],
  590. (UUID)data[4], (string)data[5]);
  591. linfo.m_active=(bool)data[0];
  592. return linfo;
  593. }
  594. public UUID GetItemID()
  595. {
  596. return m_itemID;
  597. }
  598. public UUID GetHostID()
  599. {
  600. return m_hostID;
  601. }
  602. public int GetChannel()
  603. {
  604. return m_channel;
  605. }
  606. public uint GetLocalID()
  607. {
  608. return m_localID;
  609. }
  610. public int GetHandle()
  611. {
  612. return m_handle;
  613. }
  614. public string GetMessage()
  615. {
  616. return m_message;
  617. }
  618. public string GetName()
  619. {
  620. return m_name;
  621. }
  622. public bool IsActive()
  623. {
  624. return m_active;
  625. }
  626. public void Deactivate()
  627. {
  628. m_active = false;
  629. }
  630. public void Activate()
  631. {
  632. m_active = true;
  633. }
  634. public UUID GetID()
  635. {
  636. return m_id;
  637. }
  638. }
  639. }