From a993d0d3351f15510e404cc09951723cf5c435fb Mon Sep 17 00:00:00 2001
From: Tedd Hansen
Date: Sat, 12 Jan 2008 10:25:08 +0000
Subject: 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.
---
.../ScriptEngine/Common/ScriptServerInterfaces.cs | 3 +
OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs | 7 ++-
.../ScriptEngine/DotNetEngine/EventManager.cs | 66 +++++++++++++++-------
.../ScriptEngine/DotNetEngine/EventQueueManager.cs | 4 +-
.../ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs | 8 +++
.../ScriptEngine/DotNetEngine/ScriptEngine.cs | 6 +-
.../ScriptEngine/RemoteServer/EventManager.cs | 3 +-
7 files changed, 69 insertions(+), 28 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
index 14b97b8..23ef126 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
@@ -1,5 +1,7 @@
using libsecondlife;
using OpenSim.Framework;
+using OpenSim.Framework.Console;
+using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.ScriptEngine.Common
{
@@ -50,6 +52,7 @@ namespace OpenSim.Region.ScriptEngine.Common
public interface ScriptEngine
{
RemoteEvents EventManager();
+ void InitializeEngine(Scene Sceneworld, LogBase logger, bool DontHookUp);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs b/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs
index b6c2e93..10abc35 100644
--- a/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs
+++ b/OpenSim/Region/ScriptEngine/Common/TRPC_Remote.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
+using libsecondlife;
using OpenSim.Region.ScriptEngine.Common.TRPC;
namespace OpenSim.Region.ScriptEngine.Common
@@ -22,7 +23,11 @@ namespace OpenSim.Region.ScriptEngine.Common
typeof(System.Int64),
typeof(System.Double),
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
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
index ad29feb..a36691d 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
@@ -55,34 +55,30 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
private ScriptEngine myScriptEngine;
//public IScriptHost TEMP_OBJECT_ID;
- public EventManager(ScriptEngine _ScriptEngine)
+ public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
{
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
- 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;
+ // Hook up to events from OpenSim
+ // We may not want to do it because someone is controlling us and will deliver events to us
+ if (performHookUp)
+ {
+ 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)
{
// 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});
}
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: " +
script.Length);
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
@@ -90,10 +86,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
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());
myScriptEngine.m_ScriptManager.StopScript(
localID,
@@ -102,134 +94,166 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
// 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
// then queued in EventQueueManager.
// 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)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit");
}
- //public void touch_start(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)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end");
}
public void collision_start(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start");
}
public void collision(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision");
}
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)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start");
}
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)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end");
}
+ // Handled by long commands
public void timer(uint localID, LLUUID itemID)
{
+ //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "");
}
public void listen(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen");
}
public void on_rez(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez");
}
public void sensor(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor");
}
public void no_sensor(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor");
}
public void control(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control");
}
public void money(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money");
}
public void email(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email");
}
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)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target");
}
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)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target");
}
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)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed");
}
public void attach(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach");
}
public void dataserver(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver");
}
public void link_message(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message");
}
public void moving_start(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start");
}
public void moving_end(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end");
}
public void object_rez(uint localID, LLUUID itemID)
{
+ myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez");
}
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)
{
+ // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response");
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
index e2b11cc..e7cb489 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
@@ -314,7 +314,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
///
/// Name of the function, will be state + "_event_" + FunctionName
/// Array of parameters to match event mask
- 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
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
@@ -345,7 +345,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
///
/// Name of the function, will be state + "_event_" + FunctionName
/// Array of parameters to match event mask
- 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)
{
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
index e403385..1e4dc99 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
@@ -202,6 +202,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void CheckHttpRequests()
{
+ if (m_ScriptEngine.World == null)
+ return;
+
IHttpRequests iHttpReq =
m_ScriptEngine.World.RequestModuleInterface();
@@ -241,6 +244,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void CheckXMLRPCRequests()
{
+ if (m_ScriptEngine.World == null)
+ return;
+
IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface();
if (xmlrpc != null)
@@ -266,6 +272,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void CheckListeners()
{
+ if (m_ScriptEngine.World == null)
+ return;
IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface();
while (comms.HasMessages())
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index 604a5f3..c3cb34d 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
get { return m_log; }
}
- public void InitializeEngine(Scene Sceneworld, LogBase logger)
+ public void InitializeEngine(Scene Sceneworld, LogBase logger, bool HookUpToServer)
{
World = Sceneworld;
m_log = logger;
@@ -73,7 +73,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Create all objects we'll be using
m_EventQueueManager = new EventQueueManager(this);
- m_EventManager = new EventManager(this);
+ m_EventManager = new EventManager(this, HookUpToServer);
m_ScriptManager = new ScriptManager(this);
m_AppDomainManager = new AppDomainManager();
m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
@@ -97,7 +97,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void Initialise(Scene scene, IConfigSource config)
{
- InitializeEngine(scene, MainLog.Instance);
+ InitializeEngine(scene, MainLog.Instance, true);
}
public void PostInitialise()
diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
index 39f2695..047ff2e 100644
--- a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
@@ -87,7 +87,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
myScriptEngine.Log.Verbose("RemoteEngine", "Creating new script (with connection)");
// 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);
//remoteScript.Add(localID, obj);
@@ -99,6 +99,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
{
//remoteScript[localID].Events.touch_start(localID, offsetPos, remoteClient);
+ RPC.SendCommand(myScriptServerID, "touch_start", offsetPos, "How to transfer IClientAPI?");
}
--
cgit v1.1