From 6055db2bc3beadcfd3e06c74b0fffb42ae4545a7 Mon Sep 17 00:00:00 2001
From: Tedd Hansen
Date: Sun, 30 Dec 2007 22:37:07 +0000
Subject: server->script event path almost ready for remote scriptengine
(translation table between local script ID and remote script ID missing)
---
OpenSim/Grid/ScriptServer/RemotingObject.cs | 24 +++++++
OpenSim/Grid/ScriptServer/RemotingServer.cs | 28 ++++++++
.../ScriptEngine/DotNetEngine/EventManager.cs | 70 +++++++++---------
.../ScriptEngine/DotNetEngine/ScriptEngine.cs | 17 ++---
.../ScriptEngine/RemoteServer/EventManager.cs | 84 ++++++++++++----------
.../ScriptEngine/RemoteServer/RemoteServer.cs | 38 ++++++++++
.../ScriptEngine/RemoteServer/ScriptEngine.cs | 3 +
7 files changed, 179 insertions(+), 85 deletions(-)
create mode 100644 OpenSim/Grid/ScriptServer/RemotingObject.cs
create mode 100644 OpenSim/Grid/ScriptServer/RemotingServer.cs
create mode 100644 OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Grid/ScriptServer/RemotingObject.cs b/OpenSim/Grid/ScriptServer/RemotingObject.cs
new file mode 100644
index 0000000..f095ca4
--- /dev/null
+++ b/OpenSim/Grid/ScriptServer/RemotingObject.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Region.Environment.Interfaces;
+
+namespace OpenSim.Grid.ScriptServer
+{
+ public class RemotingObject : MarshalByRefObject
+ {
+ // This object will be exposed over remoting. It is a singleton, so it exists only in as one instance.
+
+ // Expose ScriptEngine
+ public OpenSim.Region.ScriptEngine.DotNetEngine.ScriptEngine ScriptEngine = new OpenSim.Region.ScriptEngine.DotNetEngine.ScriptEngine();
+
+ ///
+ /// Receives calls from remote grids.
+ ///
+ ///
+ public OpenSim.Region.ScriptEngine.DotNetEngine.ScriptEngine GetScriptEngine()
+ {
+ return ScriptEngine;
+ }
+ }
+}
diff --git a/OpenSim/Grid/ScriptServer/RemotingServer.cs b/OpenSim/Grid/ScriptServer/RemotingServer.cs
new file mode 100644
index 0000000..3ec3e64
--- /dev/null
+++ b/OpenSim/Grid/ScriptServer/RemotingServer.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+
+
+namespace OpenSim.Grid.ScriptServer
+{
+ class RemotingServer
+ {
+
+ public void CreateServer(int port, string instanceName)
+ {
+ // Create an instance of a channel
+ TcpChannel channel = new TcpChannel(port);
+ ChannelServices.RegisterChannel(channel, true);
+
+ // Register as an available service with the name HelloWorld
+ RemotingConfiguration.RegisterWellKnownServiceType(
+ typeof(RemotingObject),
+ instanceName,
+ WellKnownObjectMode.Singleton);
+
+ }
+ }
+}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
index ced5025..16182f9 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
///
[Serializable]
- internal class EventManager
+ public class EventManager
{
//
@@ -46,7 +46,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// This class it the link between an event inside OpenSim and the corresponding event in a user script being executed.
//
// For example when an user touches an object then the "myScriptEngine.World.EventManager.OnObjectGrab" event is fired inside OpenSim.
- // We hook up to this event and queue a touch_start in EventQueueManager with the proper LSL parameters. It will then be delivered to the script by EventQueueManager.
+ // We hook up to this event and queue a touch_start in EventQueueManager with the proper LSL parameters.
+ // It will then be delivered to the script by EventQueueManager.
+ //
// You can check debug C# dump of an LSL script if you need to verify what exact parameters are needed.
//
@@ -105,128 +107,128 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// When queued in EventQueueManager they need to be LSL compatible (name and params)
//public void state_entry() { } //
- public void state_exit()
+ public void state_exit(uint localID, LLUUID itemID)
{
}
- //public void touch_start() { }
- public void touch()
+ //public void touch_start(uint localID, LLUUID itemID) { }
+ public void touch(uint localID, LLUUID itemID)
{
}
- public void touch_end()
+ public void touch_end(uint localID, LLUUID itemID)
{
}
- public void collision_start()
+ public void collision_start(uint localID, LLUUID itemID)
{
}
- public void collision()
+ public void collision(uint localID, LLUUID itemID)
{
}
- public void collision_end()
+ public void collision_end(uint localID, LLUUID itemID)
{
}
- public void land_collision_start()
+ public void land_collision_start(uint localID, LLUUID itemID)
{
}
- public void land_collision()
+ public void land_collision(uint localID, LLUUID itemID)
{
}
- public void land_collision_end()
+ public void land_collision_end(uint localID, LLUUID itemID)
{
}
- public void timer()
+ public void timer(uint localID, LLUUID itemID)
{
}
- public void listen()
+ public void listen(uint localID, LLUUID itemID)
{
}
- public void on_rez()
+ public void on_rez(uint localID, LLUUID itemID)
{
}
- public void sensor()
+ public void sensor(uint localID, LLUUID itemID)
{
}
- public void no_sensor()
+ public void no_sensor(uint localID, LLUUID itemID)
{
}
- public void control()
+ public void control(uint localID, LLUUID itemID)
{
}
- public void money()
+ public void money(uint localID, LLUUID itemID)
{
}
- public void email()
+ public void email(uint localID, LLUUID itemID)
{
}
- public void at_target()
+ public void at_target(uint localID, LLUUID itemID)
{
}
- public void not_at_target()
+ public void not_at_target(uint localID, LLUUID itemID)
{
}
- public void at_rot_target()
+ public void at_rot_target(uint localID, LLUUID itemID)
{
}
- public void not_at_rot_target()
+ public void not_at_rot_target(uint localID, LLUUID itemID)
{
}
- public void run_time_permissions()
+ public void run_time_permissions(uint localID, LLUUID itemID)
{
}
- public void changed()
+ public void changed(uint localID, LLUUID itemID)
{
}
- public void attach()
+ public void attach(uint localID, LLUUID itemID)
{
}
- public void dataserver()
+ public void dataserver(uint localID, LLUUID itemID)
{
}
- public void link_message()
+ public void link_message(uint localID, LLUUID itemID)
{
}
- public void moving_start()
+ public void moving_start(uint localID, LLUUID itemID)
{
}
- public void moving_end()
+ public void moving_end(uint localID, LLUUID itemID)
{
}
- public void object_rez()
+ public void object_rez(uint localID, LLUUID itemID)
{
}
- public void remote_data()
+ public void remote_data(uint localID, LLUUID itemID)
{
}
- public void http_response()
+ public void http_response(uint localID, LLUUID itemID)
{
}
}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index fabce6a..11419be 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -41,10 +41,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
[Serializable]
public class ScriptEngine : IRegionModule
{
- internal Scene World;
- internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim
+ public Scene World;
+ public EventManager m_EventManager; // Handles and queues incoming events from OpenSim
internal EventQueueManager m_EventQueueManager; // Executes events
- internal ScriptManager m_ScriptManager; // Load, unload and execute scripts
+ public ScriptManager m_ScriptManager; // Load, unload and execute scripts
internal AppDomainManager m_AppDomainManager;
internal LSLLongCmdHandler m_LSLLongCmdHandler;
@@ -86,14 +86,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// We are shutting down
}
- //// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app)
- //[Obsolete("!!!FOR DEBUGGING ONLY!!!")]
- //public void StartScript(string ScriptID, IScriptHost ObjectID)
- //{
- // this.myEventManager.TEMP_OBJECT_ID = ObjectID;
- // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
- // myScriptManager.StartScript(ScriptID, ObjectID);
- //}
+
#region IRegionModule
@@ -112,7 +105,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public string Name
{
- get { return "LSLScriptingModule"; }
+ get { return "DotNetEngine"; }
}
public bool IsSharedModule
diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
index b4ac615..f0a3aa1 100644
--- a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
internal class EventManager
{
- System.Collections.Generic.Dictionary remoteScript = new System.Collections.Generic.Dictionary();
+ System.Collections.Generic.Dictionary remoteScript = new System.Collections.Generic.Dictionary();
private ScriptEngine myScriptEngine;
@@ -47,179 +47,185 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
myScriptEngine = _ScriptEngine;
myScriptEngine.Log.Verbose("RemoteEngine", "Hooking up to server events");
- myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
+ //myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
- myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
+ //myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
+
+
}
- public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
+
+ public void OnRezScript(uint localID, LLUUID itemID, string script)
{
- remoteScript[localID].touch_start(localID, offsetPos, remoteClient);
+ // WE ARE CREATING A NEW SCRIPT ... CREATE SCRIPT, GET A REMOTEID THAT WE MAP FROM LOCALID
+ OpenSim.Grid.ScriptServer.RemotingObject obj = myScriptEngine.m_RemoteServer.Connect("localhost", 1234);
+ remoteScript.Add(localID, obj);
+ remoteScript[localID].ScriptEngine.m_EventManager.OnRezScript(localID, itemID, script);
}
- public void OnRezScript(uint localID, LLUUID itemID, string script)
+ public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
{
- remoteScript[localID].OnRezScript(localID, itemID, script);
+ remoteScript[localID].ScriptEngine.m_EventManager.touch_start(localID, offsetPos, remoteClient);
}
public void OnRemoveScript(uint localID, LLUUID itemID)
{
- remoteScript[localID].OnRemoveScript(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.OnRemoveScript(localID, itemID);
}
public void state_exit(uint localID, LLUUID itemID)
{
- remoteScript[localID].state_exit(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.state_exit(localID, itemID);
}
public void touch(uint localID, LLUUID itemID)
{
- remoteScript[localID].touch(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.touch(localID, itemID);
}
public void touch_end(uint localID, LLUUID itemID)
{
- remoteScript[localID].touch_end(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.touch_end(localID, itemID);
}
public void collision_start(uint localID, LLUUID itemID)
{
- remoteScript[localID].collision_start(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.collision_start(localID, itemID);
}
public void collision(uint localID, LLUUID itemID)
{
- remoteScript[localID].collision(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.collision(localID, itemID);
}
public void collision_end(uint localID, LLUUID itemID)
{
- remoteScript[localID].collision_end(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.collision_end(localID, itemID);
}
public void land_collision_start(uint localID, LLUUID itemID)
{
- remoteScript[localID].land_collision_start(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.land_collision_start(localID, itemID);
}
public void land_collision(uint localID, LLUUID itemID)
{
- remoteScript[localID].land_collision(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.land_collision(localID, itemID);
}
public void land_collision_end(uint localID, LLUUID itemID)
{
- remoteScript[localID].land_collision_end(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.land_collision_end(localID, itemID);
}
public void timer(uint localID, LLUUID itemID)
{
- remoteScript[localID].timer(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.timer(localID, itemID);
}
public void listen(uint localID, LLUUID itemID)
{
- remoteScript[localID].listen(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.listen(localID, itemID);
}
public void on_rez(uint localID, LLUUID itemID)
{
- remoteScript[localID].on_rez(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.on_rez(localID, itemID);
}
public void sensor(uint localID, LLUUID itemID)
{
- remoteScript[localID].sensor(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.sensor(localID, itemID);
}
public void no_sensor(uint localID, LLUUID itemID)
{
- remoteScript[localID].no_sensor(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.no_sensor(localID, itemID);
}
public void control(uint localID, LLUUID itemID)
{
- remoteScript[localID].control(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.control(localID, itemID);
}
public void money(uint localID, LLUUID itemID)
{
- remoteScript[localID].money(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.money(localID, itemID);
}
public void email(uint localID, LLUUID itemID)
{
- remoteScript[localID].email(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.email(localID, itemID);
}
public void at_target(uint localID, LLUUID itemID)
{
- remoteScript[localID].at_target(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.at_target(localID, itemID);
}
public void not_at_target(uint localID, LLUUID itemID)
{
- remoteScript[localID].not_at_target(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.not_at_target(localID, itemID);
}
public void at_rot_target(uint localID, LLUUID itemID)
{
- remoteScript[localID].at_rot_target(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.at_rot_target(localID, itemID);
}
public void not_at_rot_target(uint localID, LLUUID itemID)
{
- remoteScript[localID].not_at_rot_target(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.not_at_rot_target(localID, itemID);
}
public void run_time_permissions(uint localID, LLUUID itemID)
{
- remoteScript[localID].run_time_permissions(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.run_time_permissions(localID, itemID);
}
public void changed(uint localID, LLUUID itemID)
{
- remoteScript[localID].changed(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.changed(localID, itemID);
}
public void attach(uint localID, LLUUID itemID)
{
- remoteScript[localID].attach(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.attach(localID, itemID);
}
public void dataserver(uint localID, LLUUID itemID)
{
- remoteScript[localID].dataserver(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.dataserver(localID, itemID);
}
public void link_message(uint localID, LLUUID itemID)
{
- remoteScript[localID].link_message(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.link_message(localID, itemID);
}
public void moving_start(uint localID, LLUUID itemID)
{
- remoteScript[localID].moving_start(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.moving_start(localID, itemID);
}
public void moving_end(uint localID, LLUUID itemID)
{
- remoteScript[localID].moving_end(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.moving_end(localID, itemID);
}
public void object_rez(uint localID, LLUUID itemID)
{
- remoteScript[localID].object_rez(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.object_rez(localID, itemID);
}
public void remote_data(uint localID, LLUUID itemID)
{
- remoteScript[localID].remote_data(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.remote_data(localID, itemID);
}
public void http_response(uint localID, LLUUID itemID)
{
- remoteScript[localID].http_response(localID, itemID);
+ remoteScript[localID].ScriptEngine.m_EventManager.http_response(localID, itemID);
}
}
diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs b/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs
new file mode 100644
index 0000000..423e6be
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+
+namespace OpenSim.Region.ScriptEngine.RemoteServer
+{
+ class RemoteServer
+ {
+
+ public OpenSim.Grid.ScriptServer.RemotingObject Connect(string hostname, int port)
+ {
+ // Create a channel for communicating w/ the remote object
+ // Notice no port is specified on the client
+ TcpChannel chan = new TcpChannel();
+ ChannelServices.RegisterChannel(chan, true);
+
+ // Create an instance of the remote object
+ OpenSim.Grid.ScriptServer.RemotingObject obj = (OpenSim.Grid.ScriptServer.RemotingObject)Activator.GetObject(
+ typeof(OpenSim.Grid.ScriptServer.RemotingObject),
+ "tcp://" + hostname + ":" + port + "/DotNetEngine");
+
+ // Use the object
+ if (obj.Equals(null))
+ {
+ System.Console.WriteLine("Error: unable to locate server");
+ }
+ else
+ {
+ return obj;
+ }
+ return null;
+
+ }
+ }
+}
diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/RemoteServer/ScriptEngine.cs
index ae29ad5..679d5d4 100644
--- a/OpenSim/Region/ScriptEngine/RemoteServer/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/RemoteServer/ScriptEngine.cs
@@ -43,6 +43,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
{
internal Scene World;
internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim
+ internal RemoteServer m_RemoteServer;
private LogBase m_log;
@@ -64,6 +65,8 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
Log.Verbose("ScriptEngine", "RemoteEngine (Remote Script Server) initializing");
// Create all objects we'll be using
m_EventManager = new EventManager(this);
+ m_RemoteServer = new RemoteServer();
+ m_RemoteServer.Connect("localhost", 1234);
}
public void Shutdown()
--
cgit v1.1