From 373d801c400f8c4da8bc55ed8637a42be8c6e927 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 30 Dec 2007 23:56:29 +0000 Subject: * Added graceful remote script server connection error handling * Removed a friends module test that I had. --- .../ScriptEngine/RemoteServer/EventManager.cs | 304 ++++++++++++++++++--- .../ScriptEngine/RemoteServer/RemoteServer.cs | 36 ++- 2 files changed, 296 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs index 1e56b94..5561563 100644 --- a/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/RemoteServer/EventManager.cs @@ -63,172 +63,410 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer // 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); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.OnRezScript(localID, itemID, script); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) { - remoteScript[localID].ScriptEngine.m_EventManager.touch_start(localID, offsetPos, remoteClient); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.touch_start(localID, offsetPos, remoteClient); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void OnRemoveScript(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.OnRemoveScript(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.OnRemoveScript(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void state_exit(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.state_exit(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.state_exit(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void touch(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.touch(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.touch(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void touch_end(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.touch_end(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.touch_end(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void collision_start(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.collision_start(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.collision_start(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void collision(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.collision(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.collision(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void collision_end(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.collision_end(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.collision_end(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void land_collision_start(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.land_collision_start(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.land_collision_start(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void land_collision(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.land_collision(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.land_collision(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void land_collision_end(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.land_collision_end(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.land_collision_end(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void timer(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.timer(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.timer(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void listen(uint localID, LLUUID itemID) { + try + { remoteScript[localID].ScriptEngine.m_EventManager.listen(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void on_rez(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.on_rez(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.on_rez(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void sensor(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.sensor(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.sensor(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void no_sensor(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.no_sensor(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.no_sensor(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void control(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.control(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.control(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void money(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.money(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.money(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void email(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.email(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.email(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void at_target(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.at_target(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.at_target(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void not_at_target(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.not_at_target(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.not_at_target(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void at_rot_target(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.at_rot_target(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.at_rot_target(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void not_at_rot_target(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.not_at_rot_target(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.not_at_rot_target(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void run_time_permissions(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.run_time_permissions(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.run_time_permissions(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void changed(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.changed(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.changed(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void attach(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.attach(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.attach(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void dataserver(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.dataserver(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.dataserver(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void link_message(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.link_message(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.link_message(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void moving_start(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.moving_start(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.moving_start(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void moving_end(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.moving_end(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.moving_end(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void object_rez(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.object_rez(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.object_rez(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void remote_data(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.remote_data(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.remote_data(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } public void http_response(uint localID, LLUUID itemID) { - remoteScript[localID].ScriptEngine.m_EventManager.http_response(localID, itemID); + try + { + remoteScript[localID].ScriptEngine.m_EventManager.http_response(localID, itemID); + } + catch (System.NullReferenceException) + { + OpenSim.Framework.Console.MainLog.Instance.Error("SCRIPTS", "Error Connecting to Remote Script Server. Is it running?"); + } } } diff --git a/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs b/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs index 1a528c8..4fff20d 100644 --- a/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs +++ b/OpenSim/Region/ScriptEngine/RemoteServer/RemoteServer.cs @@ -17,21 +17,35 @@ namespace OpenSim.Region.ScriptEngine.RemoteServer // 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); + try + { + ChannelServices.RegisterChannel(chan, true); + } + catch (System.Runtime.Remoting.RemotingException) + { + System.Console.WriteLine("Error: tcp already registered, RemoteServer.cs in OpenSim.Region.ScriptEngine.RemoteServer line 24"); + } + try + { - // 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"); + // 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"); + // Use the object + if (obj.Equals(null)) + { + System.Console.WriteLine("Error: unable to locate server"); + } + else + { + return obj; + } } - else + catch (System.Net.Sockets.SocketException) { - return obj; + System.Console.WriteLine("Error: unable to connect to server"); } return null; -- cgit v1.1