aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-01-12 14:30:22 +0000
committerTedd Hansen2008-01-12 14:30:22 +0000
commitbacbade369a5244f9bcc611488b59f3bd4c8a564 (patch)
tree2cd909eff401066a69dba96615cbf736fdd73be5 /OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
parent* Trying something to see if it helps teleports and border crossings (diff)
downloadopensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.zip
opensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.tar.gz
opensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.tar.bz2
opensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.tar.xz
Major reorganizing of DotNetEngine. Moved common script engine parts to ScriptEngine.Common, only .Net-specific code in DotNetEngine. AppDomains, event handling, event execution queue and multithreading, script load/unload queue, etc has been moved to ScriptEngine.Common.
Loads of things has been put into interfaces instead of the specific class. We are now one step closer to ScriptServer, and its very easy to implement new script languages. Just a few lines required to make them a OpenSim script module with all its glory.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs (renamed from OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs)516
1 files changed, 258 insertions, 258 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index a36691d..a5ad911 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -1,259 +1,259 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28/* Original code: Tedd Hansen */ 28/* Original code: Tedd Hansen */
29using System; 29using System;
30using libsecondlife; 30using libsecondlife;
31using OpenSim.Framework; 31using OpenSim.Framework;
32 32
33namespace OpenSim.Region.ScriptEngine.DotNetEngine 33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it. 36 /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
37 /// </summary> 37 /// </summary>
38 [Serializable] 38 [Serializable]
39 public class EventManager : OpenSim.Region.ScriptEngine.Common.ScriptServerInterfaces.RemoteEvents 39 public class EventManager : OpenSim.Region.ScriptEngine.Common.ScriptServerInterfaces.RemoteEvents
40 { 40 {
41 41
42 // 42 //
43 // Class is instanced in "ScriptEngine" and Uses "EventQueueManager" that is also instanced in "ScriptEngine". 43 // Class is instanced in "ScriptEngine" and Uses "EventQueueManager" that is also instanced in "ScriptEngine".
44 // This class needs a bit of explaining: 44 // This class needs a bit of explaining:
45 // 45 //
46 // This class it the link between an event inside OpenSim and the corresponding event in a user script being executed. 46 // This class it the link between an event inside OpenSim and the corresponding event in a user script being executed.
47 // 47 //
48 // For example when an user touches an object then the "myScriptEngine.World.EventManager.OnObjectGrab" event is fired inside OpenSim. 48 // For example when an user touches an object then the "myScriptEngine.World.EventManager.OnObjectGrab" event is fired inside OpenSim.
49 // We hook up to this event and queue a touch_start in EventQueueManager with the proper LSL parameters. 49 // We hook up to this event and queue a touch_start in EventQueueManager with the proper LSL parameters.
50 // It will then be delivered to the script by EventQueueManager. 50 // It will then be delivered to the script by EventQueueManager.
51 // 51 //
52 // You can check debug C# dump of an LSL script if you need to verify what exact parameters are needed. 52 // You can check debug C# dump of an LSL script if you need to verify what exact parameters are needed.
53 // 53 //
54 54
55 55
56 private ScriptEngine myScriptEngine; 56 private ScriptEngine myScriptEngine;
57 //public IScriptHost TEMP_OBJECT_ID; 57 //public IScriptHost TEMP_OBJECT_ID;
58 public EventManager(ScriptEngine _ScriptEngine, bool performHookUp) 58 public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
59 { 59 {
60 myScriptEngine = _ScriptEngine; 60 myScriptEngine = _ScriptEngine;
61 61
62 // Hook up to events from OpenSim 62 // Hook up to events from OpenSim
63 // We may not want to do it because someone is controlling us and will deliver events to us 63 // We may not want to do it because someone is controlling us and will deliver events to us
64 if (performHookUp) 64 if (performHookUp)
65 { 65 {
66 myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events"); 66 myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events");
67 myScriptEngine.World.EventManager.OnObjectGrab += touch_start; 67 myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
68 myScriptEngine.World.EventManager.OnRezScript += OnRezScript; 68 myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
69 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; 69 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
70 // TODO: HOOK ALL EVENTS UP TO SERVER! 70 // TODO: HOOK ALL EVENTS UP TO SERVER!
71 } 71 }
72 } 72 }
73 73
74 public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) 74 public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
75 { 75 {
76 // Add to queue for all scripts in ObjectID object 76 // Add to queue for all scripts in ObjectID object
77 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1}); 77 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
78 } 78 }
79 79
80 public void OnRezScript(uint localID, LLUUID itemID, string script) 80 public void OnRezScript(uint localID, LLUUID itemID, string script)
81 { 81 {
82 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + 82 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
83 script.Length); 83 script.Length);
84 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script); 84 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
85 } 85 }
86 86
87 public void OnRemoveScript(uint localID, LLUUID itemID) 87 public void OnRemoveScript(uint localID, LLUUID itemID)
88 { 88 {
89 Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString()); 89 Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
90 myScriptEngine.m_ScriptManager.StopScript( 90 myScriptEngine.m_ScriptManager.StopScript(
91 localID, 91 localID,
92 itemID 92 itemID
93 ); 93 );
94 } 94 }
95 95
96 // TODO: Replace placeholders below 96 // TODO: Replace placeholders below
97 // NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT! 97 // NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT!
98 // These needs to be hooked up to OpenSim during init of this class 98 // These needs to be hooked up to OpenSim during init of this class
99 // then queued in EventQueueManager. 99 // then queued in EventQueueManager.
100 // When queued in EventQueueManager they need to be LSL compatible (name and params) 100 // When queued in EventQueueManager they need to be LSL compatible (name and params)
101 101
102 public void state_exit(uint localID, LLUUID itemID) 102 public void state_exit(uint localID, LLUUID itemID)
103 { 103 {
104 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit"); 104 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit");
105 } 105 }
106 106
107 public void touch(uint localID, LLUUID itemID) 107 public void touch(uint localID, LLUUID itemID)
108 { 108 {
109 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch"); 109 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch");
110 } 110 }
111 111
112 public void touch_end(uint localID, LLUUID itemID) 112 public void touch_end(uint localID, LLUUID itemID)
113 { 113 {
114 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end"); 114 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end");
115 } 115 }
116 116
117 public void collision_start(uint localID, LLUUID itemID) 117 public void collision_start(uint localID, LLUUID itemID)
118 { 118 {
119 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start"); 119 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start");
120 } 120 }
121 121
122 public void collision(uint localID, LLUUID itemID) 122 public void collision(uint localID, LLUUID itemID)
123 { 123 {
124 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision"); 124 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision");
125 } 125 }
126 126
127 public void collision_end(uint localID, LLUUID itemID) 127 public void collision_end(uint localID, LLUUID itemID)
128 { 128 {
129 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end"); 129 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end");
130 } 130 }
131 131
132 public void land_collision_start(uint localID, LLUUID itemID) 132 public void land_collision_start(uint localID, LLUUID itemID)
133 { 133 {
134 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start"); 134 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start");
135 } 135 }
136 136
137 public void land_collision(uint localID, LLUUID itemID) 137 public void land_collision(uint localID, LLUUID itemID)
138 { 138 {
139 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision"); 139 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision");
140 } 140 }
141 141
142 public void land_collision_end(uint localID, LLUUID itemID) 142 public void land_collision_end(uint localID, LLUUID itemID)
143 { 143 {
144 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end"); 144 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end");
145 } 145 }
146 146
147 // Handled by long commands 147 // Handled by long commands
148 public void timer(uint localID, LLUUID itemID) 148 public void timer(uint localID, LLUUID itemID)
149 { 149 {
150 //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, ""); 150 //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "");
151 } 151 }
152 152
153 public void listen(uint localID, LLUUID itemID) 153 public void listen(uint localID, LLUUID itemID)
154 { 154 {
155 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen"); 155 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen");
156 } 156 }
157 157
158 public void on_rez(uint localID, LLUUID itemID) 158 public void on_rez(uint localID, LLUUID itemID)
159 { 159 {
160 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez"); 160 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez");
161 } 161 }
162 162
163 public void sensor(uint localID, LLUUID itemID) 163 public void sensor(uint localID, LLUUID itemID)
164 { 164 {
165 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor"); 165 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor");
166 } 166 }
167 167
168 public void no_sensor(uint localID, LLUUID itemID) 168 public void no_sensor(uint localID, LLUUID itemID)
169 { 169 {
170 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor"); 170 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor");
171 } 171 }
172 172
173 public void control(uint localID, LLUUID itemID) 173 public void control(uint localID, LLUUID itemID)
174 { 174 {
175 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control"); 175 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control");
176 } 176 }
177 177
178 public void money(uint localID, LLUUID itemID) 178 public void money(uint localID, LLUUID itemID)
179 { 179 {
180 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money"); 180 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money");
181 } 181 }
182 182
183 public void email(uint localID, LLUUID itemID) 183 public void email(uint localID, LLUUID itemID)
184 { 184 {
185 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email"); 185 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email");
186 } 186 }
187 187
188 public void at_target(uint localID, LLUUID itemID) 188 public void at_target(uint localID, LLUUID itemID)
189 { 189 {
190 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_target"); 190 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_target");
191 } 191 }
192 192
193 public void not_at_target(uint localID, LLUUID itemID) 193 public void not_at_target(uint localID, LLUUID itemID)
194 { 194 {
195 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target"); 195 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target");
196 } 196 }
197 197
198 public void at_rot_target(uint localID, LLUUID itemID) 198 public void at_rot_target(uint localID, LLUUID itemID)
199 { 199 {
200 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target"); 200 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target");
201 } 201 }
202 202
203 public void not_at_rot_target(uint localID, LLUUID itemID) 203 public void not_at_rot_target(uint localID, LLUUID itemID)
204 { 204 {
205 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target"); 205 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target");
206 } 206 }
207 207
208 public void run_time_permissions(uint localID, LLUUID itemID) 208 public void run_time_permissions(uint localID, LLUUID itemID)
209 { 209 {
210 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions"); 210 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions");
211 } 211 }
212 212
213 public void changed(uint localID, LLUUID itemID) 213 public void changed(uint localID, LLUUID itemID)
214 { 214 {
215 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed"); 215 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed");
216 } 216 }
217 217
218 public void attach(uint localID, LLUUID itemID) 218 public void attach(uint localID, LLUUID itemID)
219 { 219 {
220 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach"); 220 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach");
221 } 221 }
222 222
223 public void dataserver(uint localID, LLUUID itemID) 223 public void dataserver(uint localID, LLUUID itemID)
224 { 224 {
225 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver"); 225 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver");
226 } 226 }
227 227
228 public void link_message(uint localID, LLUUID itemID) 228 public void link_message(uint localID, LLUUID itemID)
229 { 229 {
230 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message"); 230 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message");
231 } 231 }
232 232
233 public void moving_start(uint localID, LLUUID itemID) 233 public void moving_start(uint localID, LLUUID itemID)
234 { 234 {
235 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start"); 235 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start");
236 } 236 }
237 237
238 public void moving_end(uint localID, LLUUID itemID) 238 public void moving_end(uint localID, LLUUID itemID)
239 { 239 {
240 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end"); 240 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end");
241 } 241 }
242 242
243 public void object_rez(uint localID, LLUUID itemID) 243 public void object_rez(uint localID, LLUUID itemID)
244 { 244 {
245 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez"); 245 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez");
246 } 246 }
247 247
248 public void remote_data(uint localID, LLUUID itemID) 248 public void remote_data(uint localID, LLUUID itemID)
249 { 249 {
250 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data"); 250 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data");
251 } 251 }
252 252
253 // Handled by long commands 253 // Handled by long commands
254 public void http_response(uint localID, LLUUID itemID) 254 public void http_response(uint localID, LLUUID itemID)
255 { 255 {
256 // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response"); 256 // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response");
257 } 257 }
258 } 258 }
259} \ No newline at end of file 259} \ No newline at end of file