ScriptServer communication is ok. Script is creatd on onrez. But since it can not access Scene it sort of crashes right away ;)

Added some sample placeholders for implementing rest of LSL events.
ThreadPoolClientBranch
Tedd Hansen 2008-01-12 10:25:08 +00:00
parent 011abad053
commit a993d0d335
9 changed files with 80 additions and 30 deletions

View File

@ -49,8 +49,8 @@ namespace OpenSim.Grid.ScriptServer
Console.WriteLine("APPLICATION EXCEPTION DETECTED"); Console.WriteLine("APPLICATION EXCEPTION DETECTED");
Console.WriteLine(""); Console.WriteLine("");
Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString()); Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString());
Console.WriteLine("Exception:"); //Console.WriteLine("Exception:");
Console.WriteLine(e.ExceptionObject.ToString()); //Console.WriteLine(e.ExceptionObject.ToString());
} }
} }
} }

View File

@ -27,6 +27,7 @@
*/ */
using System.IO; using System.IO;
using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Grid.ScriptServer.ScriptServer; using OpenSim.Grid.ScriptServer.ScriptServer;
@ -46,6 +47,7 @@ namespace OpenSim.Grid.ScriptServer
// TEMP // TEMP
public static ScriptServerInterfaces.ScriptEngine Engine; public static ScriptServerInterfaces.ScriptEngine Engine;
//public static FakeScene m_Scene = new FakeScene(null,null,null,null,null,null,null,null,null,false, false, false);
// Objects we use // Objects we use
internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
@ -64,6 +66,8 @@ namespace OpenSim.Grid.ScriptServer
// Load DotNetEngine // Load DotNetEngine
Engine = ScriptEngines.LoadEngine("DotNetEngine"); Engine = ScriptEngines.LoadEngine("DotNetEngine");
Engine.InitializeEngine(null, m_log, false);
// Set up server // Set up server
//m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine"); //m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine");
@ -85,6 +89,11 @@ namespace OpenSim.Grid.ScriptServer
m_log.Notice("SERVER", "Param " + i + ": " + p[i].ToString()); m_log.Notice("SERVER", "Param " + i + ": " + p[i].ToString());
} }
} }
if (Command == "OnRezScript")
{
Engine.EventManager().OnRezScript((uint)p[0], new LLUUID((string)p[1]), (string)p[2]);
}
} }
~ScriptServerMain() ~ScriptServerMain()

View File

@ -1,5 +1,7 @@
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.ScriptEngine.Common namespace OpenSim.Region.ScriptEngine.Common
{ {
@ -50,6 +52,7 @@ namespace OpenSim.Region.ScriptEngine.Common
public interface ScriptEngine public interface ScriptEngine
{ {
RemoteEvents EventManager(); RemoteEvents EventManager();
void InitializeEngine(Scene Sceneworld, LogBase logger, bool DontHookUp);
} }
} }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
using libsecondlife;
using OpenSim.Region.ScriptEngine.Common.TRPC; using OpenSim.Region.ScriptEngine.Common.TRPC;
namespace OpenSim.Region.ScriptEngine.Common namespace OpenSim.Region.ScriptEngine.Common
@ -22,7 +23,11 @@ namespace OpenSim.Region.ScriptEngine.Common
typeof(System.Int64), typeof(System.Int64),
typeof(System.Double), typeof(System.Double),
typeof(System.Decimal), typeof(System.Decimal),
typeof(System.Array) typeof(System.Array),
typeof(LLUUID),
typeof(System.UInt16),
typeof(System.UInt32),
typeof(System.UInt64)
}; };
// TODO: Maybe we should move queue into TCPSocket so we won't have to keep one queue instance per connection // TODO: Maybe we should move queue into TCPSocket so we won't have to keep one queue instance per connection

View File

@ -55,34 +55,30 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
private ScriptEngine myScriptEngine; private ScriptEngine myScriptEngine;
//public IScriptHost TEMP_OBJECT_ID; //public IScriptHost TEMP_OBJECT_ID;
public EventManager(ScriptEngine _ScriptEngine) public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
{ {
myScriptEngine = _ScriptEngine; myScriptEngine = _ScriptEngine;
// TODO: HOOK EVENTS UP TO SERVER!
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Start");
// TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager
// Hook up a test event to our test form // Hook up to events from OpenSim
myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events"); // We may not want to do it because someone is controlling us and will deliver events to us
myScriptEngine.World.EventManager.OnObjectGrab += touch_start; if (performHookUp)
myScriptEngine.World.EventManager.OnRezScript += OnRezScript; {
myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events");
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
// TODO: HOOK ALL EVENTS UP TO SERVER!
}
} }
public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
{ {
// Add to queue for all scripts in ObjectID object // Add to queue for all scripts in ObjectID object
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start");
//Console.WriteLine("touch_start localID: " + localID);
myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1}); myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
} }
public void OnRezScript(uint localID, LLUUID itemID, string script) public void OnRezScript(uint localID, LLUUID itemID, string script)
{ {
//myScriptEngine.myScriptManager.StartScript(
// Path.Combine("ScriptEngines", "Default.lsl"),
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
//);
Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
script.Length); script.Length);
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script); myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
@ -90,10 +86,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void OnRemoveScript(uint localID, LLUUID itemID) public void OnRemoveScript(uint localID, LLUUID itemID)
{ {
//myScriptEngine.myScriptManager.StartScript(
// Path.Combine("ScriptEngines", "Default.lsl"),
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
//);
Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString()); Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
myScriptEngine.m_ScriptManager.StopScript( myScriptEngine.m_ScriptManager.StopScript(
localID, localID,
@ -102,134 +94,166 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
// TODO: Replace placeholders below // TODO: Replace placeholders below
// NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT!
// These needs to be hooked up to OpenSim during init of this class // These needs to be hooked up to OpenSim during init of this class
// then queued in EventQueueManager. // then queued in EventQueueManager.
// When queued in EventQueueManager they need to be LSL compatible (name and params) // When queued in EventQueueManager they need to be LSL compatible (name and params)
//public void state_entry() { } //
public void state_exit(uint localID, LLUUID itemID) public void state_exit(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit");
} }
//public void touch_start(uint localID, LLUUID itemID) { }
public void touch(uint localID, LLUUID itemID) public void touch(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch");
} }
public void touch_end(uint localID, LLUUID itemID) public void touch_end(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end");
} }
public void collision_start(uint localID, LLUUID itemID) public void collision_start(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start");
} }
public void collision(uint localID, LLUUID itemID) public void collision(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision");
} }
public void collision_end(uint localID, LLUUID itemID) public void collision_end(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end");
} }
public void land_collision_start(uint localID, LLUUID itemID) public void land_collision_start(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start");
} }
public void land_collision(uint localID, LLUUID itemID) public void land_collision(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision");
} }
public void land_collision_end(uint localID, LLUUID itemID) public void land_collision_end(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end");
} }
// Handled by long commands
public void timer(uint localID, LLUUID itemID) public void timer(uint localID, LLUUID itemID)
{ {
//myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "");
} }
public void listen(uint localID, LLUUID itemID) public void listen(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen");
} }
public void on_rez(uint localID, LLUUID itemID) public void on_rez(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez");
} }
public void sensor(uint localID, LLUUID itemID) public void sensor(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor");
} }
public void no_sensor(uint localID, LLUUID itemID) public void no_sensor(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor");
} }
public void control(uint localID, LLUUID itemID) public void control(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control");
} }
public void money(uint localID, LLUUID itemID) public void money(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money");
} }
public void email(uint localID, LLUUID itemID) public void email(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email");
} }
public void at_target(uint localID, LLUUID itemID) public void at_target(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_target");
} }
public void not_at_target(uint localID, LLUUID itemID) public void not_at_target(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target");
} }
public void at_rot_target(uint localID, LLUUID itemID) public void at_rot_target(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target");
} }
public void not_at_rot_target(uint localID, LLUUID itemID) public void not_at_rot_target(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target");
} }
public void run_time_permissions(uint localID, LLUUID itemID) public void run_time_permissions(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions");
} }
public void changed(uint localID, LLUUID itemID) public void changed(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed");
} }
public void attach(uint localID, LLUUID itemID) public void attach(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach");
} }
public void dataserver(uint localID, LLUUID itemID) public void dataserver(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver");
} }
public void link_message(uint localID, LLUUID itemID) public void link_message(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message");
} }
public void moving_start(uint localID, LLUUID itemID) public void moving_start(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start");
} }
public void moving_end(uint localID, LLUUID itemID) public void moving_end(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end");
} }
public void object_rez(uint localID, LLUUID itemID) public void object_rez(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez");
} }
public void remote_data(uint localID, LLUUID itemID) public void remote_data(uint localID, LLUUID itemID)
{ {
myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data");
} }
// Handled by long commands
public void http_response(uint localID, LLUUID itemID) public void http_response(uint localID, LLUUID itemID)
{ {
// myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response");
} }
} }
} }

View File

@ -314,7 +314,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <param name="localID"></param> /// <param name="localID"></param>
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param> /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
/// <param name="param">Array of parameters to match event mask</param> /// <param name="param">Array of parameters to match event mask</param>
public void AddToObjectQueue(uint localID, string FunctionName, object[] param) public void AddToObjectQueue(uint localID, string FunctionName, params object[] param)
{ {
// Determine all scripts in Object and add to their queue // Determine all scripts in Object and add to their queue
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
@ -345,7 +345,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// <param name="itemID"></param> /// <param name="itemID"></param>
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param> /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
/// <param name="param">Array of parameters to match event mask</param> /// <param name="param">Array of parameters to match event mask</param>
public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, object[] param) public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, params object[] param)
{ {
lock (queueLock) lock (queueLock)
{ {

View File

@ -202,6 +202,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void CheckHttpRequests() public void CheckHttpRequests()
{ {
if (m_ScriptEngine.World == null)
return;
IHttpRequests iHttpReq = IHttpRequests iHttpReq =
m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
@ -241,6 +244,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void CheckXMLRPCRequests() public void CheckXMLRPCRequests()
{ {
if (m_ScriptEngine.World == null)
return;
IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
if (xmlrpc != null) if (xmlrpc != null)
@ -266,6 +272,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void CheckListeners() public void CheckListeners()
{ {
if (m_ScriptEngine.World == null)
return;
IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
while (comms.HasMessages()) while (comms.HasMessages())

View File

@ -62,7 +62,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
get { return m_log; } get { return m_log; }
} }
public void InitializeEngine(Scene Sceneworld, LogBase logger) public void InitializeEngine(Scene Sceneworld, LogBase logger, bool HookUpToServer)
{ {
World = Sceneworld; World = Sceneworld;
m_log = logger; m_log = logger;
@ -73,7 +73,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Create all objects we'll be using // Create all objects we'll be using
m_EventQueueManager = new EventQueueManager(this); m_EventQueueManager = new EventQueueManager(this);
m_EventManager = new EventManager(this); m_EventManager = new EventManager(this, HookUpToServer);
m_ScriptManager = new ScriptManager(this); m_ScriptManager = new ScriptManager(this);
m_AppDomainManager = new AppDomainManager(); m_AppDomainManager = new AppDomainManager();
m_LSLLongCmdHandler = new LSLLongCmdHandler(this); m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
@ -97,7 +97,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
InitializeEngine(scene, MainLog.Instance); InitializeEngine(scene, MainLog.Instance, true);
} }
public void PostInitialise() public void PostInitialise()

View File

@ -87,7 +87,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
myScriptEngine.Log.Verbose("RemoteEngine", "Creating new script (with connection)"); myScriptEngine.Log.Verbose("RemoteEngine", "Creating new script (with connection)");
// Temp for now: We have one connection only - this is hardcoded in myScriptServerID // Temp for now: We have one connection only - this is hardcoded in myScriptServerID
RPC.SendCommand(myScriptServerID, "OnRezScript", script); RPC.SendCommand(myScriptServerID, "OnRezScript", localID, itemID.ToString(), script);
//ScriptServerInterfaces.ServerRemotingObject obj = myScriptEngine.m_RemoteServer.Connect("localhost", 1234); //ScriptServerInterfaces.ServerRemotingObject obj = myScriptEngine.m_RemoteServer.Connect("localhost", 1234);
//remoteScript.Add(localID, obj); //remoteScript.Add(localID, obj);
@ -99,6 +99,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
{ {
//remoteScript[localID].Events.touch_start(localID, offsetPos, remoteClient); //remoteScript[localID].Events.touch_start(localID, offsetPos, remoteClient);
RPC.SendCommand(myScriptServerID, "touch_start", offsetPos, "How to transfer IClientAPI?");
} }