From e2e692c5832143b9338b7d73f095bf6c753a3a94 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 27 May 2008 14:36:23 +0000 Subject: [PATCH] Thank you kindly, Melanie for a patch that adds: GetSerializationData() and CreateFromData() methods --- .../Environment/Interfaces/IWorldComm.cs | 4 ++ .../Scripting/WorldComm/WorldCommModule.cs | 71 +++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs index c471e7f01a..c2a55ebd74 100644 --- a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Environment.Modules.Scripting.WorldComm; @@ -40,5 +41,8 @@ namespace OpenSim.Region.Environment.Interfaces void ListenControl(LLUUID itemID, int handle, int active); void ListenRemove(LLUUID itemID, int handle); void DeleteListener(LLUUID itemID); + Object[] GetSerializationData(LLUUID itemID); + void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID, + Object[] data); } } diff --git a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs index 4ed0fb5fda..329404909c 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs @@ -330,6 +330,17 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm e.Sender.AgentId, e.Message); } + + public Object[] GetSerializationData(LLUUID itemID) + { + return m_listenerManager.GetSerializationData(itemID); + } + + public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID, + Object[] data) + { + m_listenerManager.AddFromData(localID, itemID, hostID, data); + } } public class ListenerManager @@ -549,6 +560,42 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm } return collection; } + + public Object[] GetSerializationData(LLUUID itemID) + { + List data = new List(); + + foreach (List list in m_listeners.Values) + { + foreach (ListenerInfo l in list) + { + if(l.GetItemID() == itemID) + data.AddRange(l.GetSerializationData()); + } + } + return (Object[])data.ToArray(); + } + + public void AddFromData(uint localID, LLUUID itemID, LLUUID hostID, + Object[] data) + { + int idx = 0; + Object[] item = new Object[6]; + + while(idx < data.Length) + { + Array.Copy(data, idx, item, 0, 6); + + ListenerInfo info = + ListenerInfo.FromData(localID, itemID, hostID, item); + + if(!m_listeners.ContainsKey((int)item[2])) + m_listeners.Add((int)item[2], new List()); + m_listeners[(int)item[2]].Add(info); + + idx+=6; + } + } } public class ListenerInfo @@ -587,6 +634,30 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm m_message = message; } + public Object[] GetSerializationData() + { + Object[] data = new Object[6]; + + data[0] = m_active; + data[1] = m_handle; + data[2] = m_channel; + data[3] = m_name; + data[4] = m_id; + data[5] = m_message; + + return data; + } + + public static ListenerInfo FromData(uint localID, LLUUID ItemID, LLUUID hostID, Object[] data) + { + ListenerInfo linfo = new ListenerInfo((int)data[1], localID, + ItemID, hostID, (int)data[2], (string)data[3], + (LLUUID)data[4], (string)data[5]); + linfo.m_active=(bool)data[0]; + + return linfo; + } + public LLUUID GetItemID() { return m_itemID;