diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/Executor.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | 107 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/IScript.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/TRPC/MyBase.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs | 22 |
7 files changed, 156 insertions, 64 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 0150e36..5d38b83 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -499,8 +499,17 @@ namespace OpenSim.Region.Communications.OGS1 | |||
499 | /// </summary> | 499 | /// </summary> |
500 | private void StartRemoting() | 500 | private void StartRemoting() |
501 | { | 501 | { |
502 | TcpChannel ch = new TcpChannel((int) NetworkServersInfo.RemotingListenerPort); | 502 | TcpChannel ch; |
503 | ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesnt support this. | 503 | try |
504 | { | ||
505 | ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort); | ||
506 | ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesnt support this. | ||
507 | } | ||
508 | catch (Exception ex) | ||
509 | { | ||
510 | m_log.Error("Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + "."); | ||
511 | throw (ex); | ||
512 | } | ||
504 | 513 | ||
505 | WellKnownServiceTypeEntry wellType = | 514 | WellKnownServiceTypeEntry wellType = |
506 | new WellKnownServiceTypeEntry(typeof (OGS1InterRegionRemoting), "InterRegions", | 515 | new WellKnownServiceTypeEntry(typeof (OGS1InterRegionRemoting), "InterRegions", |
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index 6262c64..e35882b 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs | |||
@@ -33,64 +33,26 @@ using System.Runtime.Remoting.Lifetime; | |||
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.Common | 34 | namespace OpenSim.Region.ScriptEngine.Common |
35 | { | 35 | { |
36 | public class Executor : MarshalByRefObject | 36 | public class Executor : ExecutorBase |
37 | { | 37 | { |
38 | // Private instance for each script | 38 | // Cache functions by keeping a reference to them in a dictionary |
39 | |||
40 | private IScript m_Script; | ||
41 | private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); | 39 | private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); |
42 | private bool m_Running = true; | ||
43 | //private List<IScript> Scripts = new List<IScript>(); | ||
44 | 40 | ||
45 | public Executor(IScript Script) | 41 | public Executor(IScript script) : base(script) |
46 | { | 42 | { |
47 | m_Script = Script; | ||
48 | } | 43 | } |
49 | 44 | ||
50 | // Object never expires | 45 | protected override void DoExecuteEvent(string FunctionName, object[] args) |
51 | public override Object InitializeLifetimeService() | ||
52 | { | ||
53 | //Console.WriteLine("Executor: InitializeLifetimeService()"); | ||
54 | // return null; | ||
55 | ILease lease = (ILease) base.InitializeLifetimeService(); | ||
56 | |||
57 | if (lease.CurrentState == LeaseState.Initial) | ||
58 | { | ||
59 | lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); | ||
60 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | ||
61 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
62 | } | ||
63 | return lease; | ||
64 | } | ||
65 | |||
66 | public AppDomain GetAppDomain() | ||
67 | { | ||
68 | return AppDomain.CurrentDomain; | ||
69 | } | ||
70 | |||
71 | public void ExecuteEvent(string FunctionName, object[] args) | ||
72 | { | 46 | { |
73 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 47 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
74 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! | 48 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! |
75 | //try | ||
76 | //{ | ||
77 | if (m_Running == false) | ||
78 | { | ||
79 | // Script is inactive, do not execute! | ||
80 | return; | ||
81 | } | ||
82 | 49 | ||
83 | string EventName = m_Script.State + "_event_" + FunctionName; | 50 | string EventName = m_Script.State + "_event_" + FunctionName; |
84 | 51 | ||
85 | //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined | ||
86 | ///#if DEBUG | 52 | ///#if DEBUG |
87 | /// Console.WriteLine("ScriptEngine: Script event function name: " + EventName); | 53 | /// Console.WriteLine("ScriptEngine: Script event function name: " + EventName); |
88 | ///#endif | 54 | ///#endif |
89 | 55 | ||
90 | //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); | ||
91 | |||
92 | //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \String.Empty + EventName + "\String.Empty); | ||
93 | |||
94 | if (Events.ContainsKey(EventName) == false) | 56 | if (Events.ContainsKey(EventName) == false) |
95 | { | 57 | { |
96 | // Not found, create | 58 | // Not found, create |
@@ -122,27 +84,9 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
122 | /// Console.WriteLine("ScriptEngine: Executing function name: " + EventName); | 84 | /// Console.WriteLine("ScriptEngine: Executing function name: " + EventName); |
123 | ///#endif | 85 | ///#endif |
124 | // Found | 86 | // Found |
125 | //try | ||
126 | //{ | ||
127 | // Invoke it | ||
128 | ev.Invoke(m_Script, args); | 87 | ev.Invoke(m_Script, args); |
129 | 88 | ||
130 | //} | ||
131 | //catch (Exception e) | ||
132 | //{ | ||
133 | // // TODO: Send to correct place | ||
134 | // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); | ||
135 | //} | ||
136 | |||
137 | |||
138 | //} | ||
139 | //catch { } | ||
140 | } | 89 | } |
141 | 90 | ||
142 | |||
143 | public void StopScript() | ||
144 | { | ||
145 | m_Running = false; | ||
146 | } | ||
147 | } | 91 | } |
148 | } \ No newline at end of file | 92 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs new file mode 100644 index 0000000..83aa230 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | |||
@@ -0,0 +1,107 @@ | |||
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 System.Collections.Generic; | ||
30 | using System.Runtime.Remoting.Lifetime; | ||
31 | using System.Text; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Common | ||
34 | { | ||
35 | public abstract class ExecutorBase : MarshalByRefObject | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Contains the script to execute functions in. | ||
39 | /// </summary> | ||
40 | protected IScript m_Script; | ||
41 | /// <summary> | ||
42 | /// If set to False events will not be executed. | ||
43 | /// </summary> | ||
44 | protected bool m_Running = true; | ||
45 | |||
46 | /// <summary> | ||
47 | /// Create a new instance of ExecutorBase | ||
48 | /// </summary> | ||
49 | /// <param name="Script"></param> | ||
50 | public ExecutorBase(IScript Script) | ||
51 | { | ||
52 | m_Script = Script; | ||
53 | } | ||
54 | |||
55 | /// <summary> | ||
56 | /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class) | ||
57 | /// </summary> | ||
58 | /// <returns></returns> | ||
59 | public override Object InitializeLifetimeService() | ||
60 | { | ||
61 | //Console.WriteLine("Executor: InitializeLifetimeService()"); | ||
62 | // return null; | ||
63 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
64 | |||
65 | if (lease.CurrentState == LeaseState.Initial) | ||
66 | { | ||
67 | lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); | ||
68 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | ||
69 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
70 | } | ||
71 | return lease; | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Get current AppDomain | ||
76 | /// </summary> | ||
77 | /// <returns>Current AppDomain</returns> | ||
78 | public AppDomain GetAppDomain() | ||
79 | { | ||
80 | return AppDomain.CurrentDomain; | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Execute a specific function/event in script. | ||
85 | /// </summary> | ||
86 | /// <param name="FunctionName">Name of function to execute</param> | ||
87 | /// <param name="args">Arguments to pass to function</param> | ||
88 | public void ExecuteEvent(string FunctionName, object[] args) | ||
89 | { | ||
90 | if (m_Running == false) | ||
91 | { | ||
92 | // Script is inactive, do not execute! | ||
93 | return; | ||
94 | } | ||
95 | } | ||
96 | protected abstract void DoExecuteEvent(string FunctionName, object[] args); | ||
97 | |||
98 | /// <summary> | ||
99 | /// Stop script from running. Event execution will be ignored. | ||
100 | /// </summary> | ||
101 | public void StopScript() | ||
102 | { | ||
103 | m_Running = false; | ||
104 | } | ||
105 | |||
106 | } | ||
107 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Common/IScript.cs b/OpenSim/Region/ScriptEngine/Common/IScript.cs index c392278..96c4e3c 100644 --- a/OpenSim/Region/ScriptEngine/Common/IScript.cs +++ b/OpenSim/Region/ScriptEngine/Common/IScript.cs | |||
@@ -33,7 +33,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
33 | public interface IScript | 33 | public interface IScript |
34 | { | 34 | { |
35 | string State { get; set; } | 35 | string State { get; set; } |
36 | Executor Exec { get; } | 36 | ExecutorBase Exec { get; } |
37 | string Source { get; set; } | 37 | string Source { get; set; } |
38 | void Start(LSL_BuiltIn_Commands_Interface BuiltIn_Commands); | 38 | void Start(LSL_BuiltIn_Commands_Interface BuiltIn_Commands); |
39 | EventQueueManager.Queue_llDetectParams_Struct llDetectParams { get; set; } | 39 | EventQueueManager.Queue_llDetectParams_Struct llDetectParams { get; set; } |
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs index b6710f0..e3d0451 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
75 | 75 | ||
76 | private Executor m_Exec; | 76 | private Executor m_Exec; |
77 | 77 | ||
78 | Executor IScript.Exec | 78 | ExecutorBase IScript.Exec |
79 | { | 79 | { |
80 | get | 80 | get |
81 | { | 81 | { |
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC/MyBase.cs b/OpenSim/Region/ScriptEngine/Common/TRPC/MyBase.cs new file mode 100644 index 0000000..1f66b14 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Common/TRPC/MyBase.cs | |||
@@ -0,0 +1,10 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.Region.ScriptEngine.Common.TRPC | ||
6 | { | ||
7 | class MyBase | ||
8 | { | ||
9 | } | ||
10 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs new file mode 100644 index 0000000..e87bec8 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs | |||
@@ -0,0 +1,22 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using OpenSim.Region.ScriptEngine.LSOEngine.LSO; | ||
6 | |||
7 | namespace OpenSim.Region.ScriptEngine.LSOEngine | ||
8 | { | ||
9 | /// <summary> | ||
10 | /// This class encapsulated an LSO file and contains execution-specific data | ||
11 | /// </summary> | ||
12 | public class LSOScript | ||
13 | { | ||
14 | private byte[] LSOCode = new byte[1024 * 16]; // Contains the LSO-file | ||
15 | //private System.IO.MemoryStream LSOCode = new MemoryStream(1024 * 16); | ||
16 | |||
17 | public void Execute(LSO_Enums.Event_Mask_Values Event, params object[] param) | ||
18 | { | ||
19 | |||
20 | } | ||
21 | } | ||
22 | } | ||