diff --git a/OpenSim/Grid/ScriptServer/Application.cs b/OpenSim/Grid/ScriptServer/Application.cs
index 7b627276d4..9893249026 100644
--- a/OpenSim/Grid/ScriptServer/Application.cs
+++ b/OpenSim/Grid/ScriptServer/Application.cs
@@ -49,8 +49,8 @@ namespace OpenSim.Grid.ScriptServer
Console.WriteLine("APPLICATION EXCEPTION DETECTED");
Console.WriteLine("");
Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString());
- Console.WriteLine("Exception:");
- Console.WriteLine(e.ExceptionObject.ToString());
+ //Console.WriteLine("Exception:");
+ //Console.WriteLine(e.ExceptionObject.ToString());
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
index f86aababe5..de70347c6d 100644
--- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
+++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs
@@ -27,6 +27,7 @@
*/
using System.IO;
+using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Grid.ScriptServer.ScriptServer;
@@ -46,6 +47,7 @@ namespace OpenSim.Grid.ScriptServer
// TEMP
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
internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
@@ -64,6 +66,8 @@ namespace OpenSim.Grid.ScriptServer
// Load DotNetEngine
Engine = ScriptEngines.LoadEngine("DotNetEngine");
+ Engine.InitializeEngine(null, m_log, false);
+
// Set up server
//m_RemotingServer = new RemotingServer(listenPort, "DotNetEngine");
@@ -85,6 +89,11 @@ namespace OpenSim.Grid.ScriptServer
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()
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
index 14b97b8b0f..23ef126862 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 b6c2e9375a..10abc35cc5 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 ad29feb51d..a36691d96b 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 e2b11cc51a..e7cb489257 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 e403385187..1e4dc99a20 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 604a5f30cf..c3cb34d3ce 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 39f26953b4..047ff2e09d 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?");
}