diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 0150e3689f..5d38b83771 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -499,8 +499,17 @@ namespace OpenSim.Region.Communications.OGS1 /// private void StartRemoting() { - TcpChannel ch = new TcpChannel((int) NetworkServersInfo.RemotingListenerPort); - ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesnt support this. + TcpChannel ch; + try + { + ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort); + ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesnt support this. + } + catch (Exception ex) + { + m_log.Error("Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + "."); + throw (ex); + } WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof (OGS1InterRegionRemoting), "InterRegions", diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index 6262c64738..e35882b659 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -33,64 +33,26 @@ using System.Runtime.Remoting.Lifetime; namespace OpenSim.Region.ScriptEngine.Common { - public class Executor : MarshalByRefObject + public class Executor : ExecutorBase { - // Private instance for each script - - private IScript m_Script; + // Cache functions by keeping a reference to them in a dictionary private Dictionary Events = new Dictionary(); - private bool m_Running = true; - //private List Scripts = new List(); - public Executor(IScript Script) + public Executor(IScript script) : base(script) { - m_Script = Script; } - // Object never expires - public override Object InitializeLifetimeService() - { - //Console.WriteLine("Executor: InitializeLifetimeService()"); - // return null; - ILease lease = (ILease) base.InitializeLifetimeService(); - - if (lease.CurrentState == LeaseState.Initial) - { - lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); -// lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); -// lease.RenewOnCallTime = TimeSpan.FromSeconds(2); - } - return lease; - } - - public AppDomain GetAppDomain() - { - return AppDomain.CurrentDomain; - } - - public void ExecuteEvent(string FunctionName, object[] args) + protected override void DoExecuteEvent(string FunctionName, object[] args) { // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! - //try - //{ - if (m_Running == false) - { - // Script is inactive, do not execute! - return; - } string EventName = m_Script.State + "_event_" + FunctionName; -//cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined ///#if DEBUG /// Console.WriteLine("ScriptEngine: Script event function name: " + EventName); ///#endif - //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); - - //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \String.Empty + EventName + "\String.Empty); - if (Events.ContainsKey(EventName) == false) { // Not found, create @@ -122,27 +84,9 @@ namespace OpenSim.Region.ScriptEngine.Common /// Console.WriteLine("ScriptEngine: Executing function name: " + EventName); ///#endif // Found - //try - //{ - // Invoke it ev.Invoke(m_Script, args); - //} - //catch (Exception e) - //{ - // // TODO: Send to correct place - // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); - //} - - - //} - //catch { } } - - public void StopScript() - { - m_Running = false; - } } } \ 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 0000000000..83aa230051 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs @@ -0,0 +1,107 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Runtime.Remoting.Lifetime; +using System.Text; + +namespace OpenSim.Region.ScriptEngine.Common +{ + public abstract class ExecutorBase : MarshalByRefObject + { + /// + /// Contains the script to execute functions in. + /// + protected IScript m_Script; + /// + /// If set to False events will not be executed. + /// + protected bool m_Running = true; + + /// + /// Create a new instance of ExecutorBase + /// + /// + public ExecutorBase(IScript Script) + { + m_Script = Script; + } + + /// + /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class) + /// + /// + public override Object InitializeLifetimeService() + { + //Console.WriteLine("Executor: InitializeLifetimeService()"); + // return null; + ILease lease = (ILease)base.InitializeLifetimeService(); + + if (lease.CurrentState == LeaseState.Initial) + { + lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); + // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); + // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); + } + return lease; + } + + /// + /// Get current AppDomain + /// + /// Current AppDomain + public AppDomain GetAppDomain() + { + return AppDomain.CurrentDomain; + } + + /// + /// Execute a specific function/event in script. + /// + /// Name of function to execute + /// Arguments to pass to function + public void ExecuteEvent(string FunctionName, object[] args) + { + if (m_Running == false) + { + // Script is inactive, do not execute! + return; + } + } + protected abstract void DoExecuteEvent(string FunctionName, object[] args); + + /// + /// Stop script from running. Event execution will be ignored. + /// + public void StopScript() + { + m_Running = false; + } + + } +} diff --git a/OpenSim/Region/ScriptEngine/Common/IScript.cs b/OpenSim/Region/ScriptEngine/Common/IScript.cs index c392278581..96c4e3c542 100644 --- a/OpenSim/Region/ScriptEngine/Common/IScript.cs +++ b/OpenSim/Region/ScriptEngine/Common/IScript.cs @@ -33,7 +33,7 @@ namespace OpenSim.Region.ScriptEngine.Common public interface IScript { string State { get; set; } - Executor Exec { get; } + ExecutorBase Exec { get; } string Source { get; set; } void Start(LSL_BuiltIn_Commands_Interface BuiltIn_Commands); 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 b6710f0037..e3d0451f66 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 private Executor m_Exec; - Executor IScript.Exec + ExecutorBase IScript.Exec { get { diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC/MyBase.cs b/OpenSim/Region/ScriptEngine/Common/TRPC/MyBase.cs new file mode 100644 index 0000000000..1f66b1495d --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Common/TRPC/MyBase.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ScriptEngine.Common.TRPC +{ + class MyBase + { + } +} diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs b/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs new file mode 100644 index 0000000000..e87bec8591 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/LSOEngine/LSOScript.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using OpenSim.Region.ScriptEngine.LSOEngine.LSO; + +namespace OpenSim.Region.ScriptEngine.LSOEngine +{ + /// + /// This class encapsulated an LSO file and contains execution-specific data + /// + public class LSOScript + { + private byte[] LSOCode = new byte[1024 * 16]; // Contains the LSO-file + //private System.IO.MemoryStream LSOCode = new MemoryStream(1024 * 16); + + public void Execute(LSO_Enums.Event_Mask_Values Event, params object[] param) + { + + } + } +} diff --git a/bin/OpenSim.32BitLaunch.exe b/bin/OpenSim.32BitLaunch.exe index fce690f860..70b46ae124 100755 Binary files a/bin/OpenSim.32BitLaunch.exe and b/bin/OpenSim.32BitLaunch.exe differ diff --git a/bin/OpenSim.32BitLaunch.pdb b/bin/OpenSim.32BitLaunch.pdb index 645e3ba3f7..f532ee21e4 100644 Binary files a/bin/OpenSim.32BitLaunch.pdb and b/bin/OpenSim.32BitLaunch.pdb differ diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 2297fc49fa..1c96534d79 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -72,6 +72,23 @@ physical_prim = true ; To run a script every few minutes, set the script filename here ; timer_Script = "filename" +; ## +; ## ScriptEngine +; ## +; These are region modules loaded into each region to provide script support +; Scripts may be everything from LSL or C# scripts put in prims to whole game systems that controls the whole grid. +; You can load multiple modules by separating them with a coma. +; +; Example: +;script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll,OpenSim.Region.ScriptEngine.RemoteServer.dll +; +; This is the current and most stable ScriptEngine: +script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll + +;Experimental remote ScriptServer plugin (does not currently work): +;script_engine = OpenSim.Region.ScriptEngine.RemoteServer.dll + + [StandAlone] accounts_authenticate = true welcome_message = "Welcome to OpenSim" @@ -138,23 +155,6 @@ msgformat = "PRIVMSG {0} : {3} - {1} of {2}" ;frame_rate = 100 -; ## -; ## ScriptEngine -; ## -; These are region modules loaded into each region to provide script support -; Scripts may be everything from LSL or C# scripts put in prims to whole game systems that controls the whole grid. -; You can load multiple modules by separating them with a coma. -; -; Example: -;script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll,OpenSim.Region.ScriptEngine.RemoteServer.dll -; -; This is the current and most stable ScriptEngine: -script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll - -;Experimental remote ScriptServer plugin (does not currently work): -;script_engine = OpenSim.Region.ScriptEngine.RemoteServer.dll - - [ScriptEngine.DotNetEngine] ; ; These settings are specific to DotNetEngine script engine