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) --- .../ScriptEngine/RemoteServer/EventManager.cs | 84 ++++++++++++---------- .../ScriptEngine/RemoteServer/RemoteServer.cs | 38 ++++++++++ .../ScriptEngine/RemoteServer/ScriptEngine.cs | 3 + 3 files changed, 86 insertions(+), 39 deletions(-) create mode 100644 OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs (limited to 'OpenSim/Region/ScriptEngine/RemoteServer') 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