diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs new file mode 100644 index 0000000..1144c00 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs | |||
@@ -0,0 +1,91 @@ | |||
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 | |||
28 | using System; | ||
29 | using libsecondlife; | ||
30 | using OpenSim.Region.Environment.Interfaces; | ||
31 | using OpenSim.Region.Environment.Modules.Scripting.WorldComm; | ||
32 | using OpenSim.Region.ScriptEngine.XEngine.Script; | ||
33 | |||
34 | namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins | ||
35 | { | ||
36 | public class Listener | ||
37 | { | ||
38 | // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
39 | |||
40 | public AsyncCommandManager m_CmdManager; | ||
41 | |||
42 | public Listener(AsyncCommandManager CmdManager) | ||
43 | { | ||
44 | m_CmdManager = CmdManager; | ||
45 | } | ||
46 | |||
47 | public void CheckListeners() | ||
48 | { | ||
49 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
50 | return; | ||
51 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
52 | |||
53 | if (comms != null) | ||
54 | { | ||
55 | while (comms.HasMessages()) | ||
56 | { | ||
57 | ListenerInfo lInfo = comms.GetNextMessage(); | ||
58 | |||
59 | //Deliver data to prim's listen handler | ||
60 | object[] resobj = new object[] | ||
61 | { | ||
62 | new LSL_Types.LSLInteger(lInfo.GetChannel()), | ||
63 | new LSL_Types.LSLString(lInfo.GetName()), | ||
64 | new LSL_Types.LSLString(lInfo.GetID().ToString()), | ||
65 | new LSL_Types.LSLString(lInfo.GetMessage()) | ||
66 | }; | ||
67 | |||
68 | m_CmdManager.m_ScriptEngine.PostScriptEvent( | ||
69 | lInfo.GetItemID(), new XEventParams( | ||
70 | "listen", resobj, | ||
71 | new XDetectParams[0])); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public Object[] GetSerializationData(LLUUID itemID) | ||
77 | { | ||
78 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
79 | |||
80 | return comms.GetSerializationData(itemID); | ||
81 | } | ||
82 | |||
83 | public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID, | ||
84 | Object[] data) | ||
85 | { | ||
86 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
87 | |||
88 | comms.CreateFromData(localID, itemID, hostID, data); | ||
89 | } | ||
90 | } | ||
91 | } | ||