Fixed ScriptEngine config in OpenSim.ini.example that was out of place.

Added some info to failure on GridServices listening port so people can see what actually went wrong.
Moved most of the function/event execution module to a baseclass so other execution methods (instead of reflection) can be used with custom script modules run by ScriptEngine.Common.
+ some accumulated patches
ThreadPoolClientBranch
Tedd Hansen 2008-02-16 07:53:02 +00:00
parent be6edefcfb
commit 169032b4a4
10 changed files with 173 additions and 81 deletions

View File

@ -499,8 +499,17 @@ namespace OpenSim.Region.Communications.OGS1
/// </summary>
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",

View File

@ -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<string, MethodInfo> Events = new Dictionary<string, MethodInfo>();
private bool m_Running = true;
//private List<IScript> Scripts = new List<IScript>();
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;
}
}
}

View File

@ -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
{
/// <summary>
/// Contains the script to execute functions in.
/// </summary>
protected IScript m_Script;
/// <summary>
/// If set to False events will not be executed.
/// </summary>
protected bool m_Running = true;
/// <summary>
/// Create a new instance of ExecutorBase
/// </summary>
/// <param name="Script"></param>
public ExecutorBase(IScript Script)
{
m_Script = Script;
}
/// <summary>
/// Make sure our object does not timeout when in AppDomain. (Called by ILease base class)
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// Get current AppDomain
/// </summary>
/// <returns>Current AppDomain</returns>
public AppDomain GetAppDomain()
{
return AppDomain.CurrentDomain;
}
/// <summary>
/// Execute a specific function/event in script.
/// </summary>
/// <param name="FunctionName">Name of function to execute</param>
/// <param name="args">Arguments to pass to function</param>
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);
/// <summary>
/// Stop script from running. Event execution will be ignored.
/// </summary>
public void StopScript()
{
m_Running = false;
}
}
}

View File

@ -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; }

View File

@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Common
private Executor m_Exec;
Executor IScript.Exec
ExecutorBase IScript.Exec
{
get
{

View File

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.ScriptEngine.Common.TRPC
{
class MyBase
{
}
}

View File

@ -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
{
/// <summary>
/// This class encapsulated an LSO file and contains execution-specific data
/// </summary>
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)
{
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -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