server->script event path almost ready for remote scriptengine (translation table between local script ID and remote script ID missing)

afrisby
Tedd Hansen 2007-12-30 22:37:07 +00:00
parent 76e74a7667
commit 6055db2bc3
7 changed files with 181 additions and 87 deletions

View File

@ -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();
/// <summary>
/// Receives calls from remote grids.
/// </summary>
/// <returns></returns>
public OpenSim.Region.ScriptEngine.DotNetEngine.ScriptEngine GetScriptEngine()
{
return ScriptEngine;
}
}
}

View File

@ -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);
}
}
}

View File

@ -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.
/// </summary>
[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)
{
}
}

View File

@ -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

View File

@ -38,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer
internal class EventManager
{
System.Collections.Generic.Dictionary<uint, EventManager> remoteScript = new System.Collections.Generic.Dictionary<uint, EventManager>();
System.Collections.Generic.Dictionary<uint, OpenSim.Grid.ScriptServer.RemotingObject> remoteScript = new System.Collections.Generic.Dictionary<uint, OpenSim.Grid.ScriptServer.RemotingObject>();
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 OnRezScript(uint localID, LLUUID itemID, string script)
{
// 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 touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
{
remoteScript[localID].touch_start(localID, offsetPos, remoteClient);
}
public void OnRezScript(uint localID, LLUUID itemID, string script)
{
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);
}
}

View File

@ -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;
}
}
}

View File

@ -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()