From 323234f82a78b8a863c12e0c6d0641ec156d523b Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Mon, 24 Sep 2007 12:49:46 +0000 Subject: Reorganized some files --- OpenSim/Grid/ScriptServer/Application.cs | 46 ++++++++ OpenSim/Grid/ScriptServer/Main.cs | 46 -------- .../Grid/ScriptServer/RegionConnectionManager.cs | 16 --- OpenSim/Grid/ScriptServer/RegionScriptDaemon.cs | 94 ---------------- OpenSim/Grid/ScriptServer/RegionsManager.cs | 19 ---- OpenSim/Grid/ScriptServer/ScriptEngineInterface.cs | 38 ------- OpenSim/Grid/ScriptServer/ScriptEngineLoader.cs | 124 --------------------- OpenSim/Grid/ScriptServer/ScriptServer.cs | 27 ----- .../ScriptServer/Region/RegionConnectionManager.cs | 16 +++ .../ScriptServer/Region/RegionScriptDaemon.cs | 94 ++++++++++++++++ .../ScriptServer/ScriptServer/RegionsManager.cs | 19 ++++ .../ScriptEngine/ScriptEngineInterface.cs | 38 +++++++ .../ScriptEngine/ScriptEngineLoader.cs | 124 +++++++++++++++++++++ OpenSim/Grid/ScriptServer/ScriptServerMain.cs | 49 ++++++++ 14 files changed, 386 insertions(+), 364 deletions(-) create mode 100644 OpenSim/Grid/ScriptServer/Application.cs delete mode 100644 OpenSim/Grid/ScriptServer/Main.cs delete mode 100644 OpenSim/Grid/ScriptServer/RegionConnectionManager.cs delete mode 100644 OpenSim/Grid/ScriptServer/RegionScriptDaemon.cs delete mode 100644 OpenSim/Grid/ScriptServer/RegionsManager.cs delete mode 100644 OpenSim/Grid/ScriptServer/ScriptEngineInterface.cs delete mode 100644 OpenSim/Grid/ScriptServer/ScriptEngineLoader.cs delete mode 100644 OpenSim/Grid/ScriptServer/ScriptServer.cs create mode 100644 OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs create mode 100644 OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionScriptDaemon.cs create mode 100644 OpenSim/Grid/ScriptServer/ScriptServer/RegionsManager.cs create mode 100644 OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineInterface.cs create mode 100644 OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineLoader.cs create mode 100644 OpenSim/Grid/ScriptServer/ScriptServerMain.cs (limited to 'OpenSim/Grid/ScriptServer') diff --git a/OpenSim/Grid/ScriptServer/Application.cs b/OpenSim/Grid/ScriptServer/Application.cs new file mode 100644 index 0000000..e7a6590 --- /dev/null +++ b/OpenSim/Grid/ScriptServer/Application.cs @@ -0,0 +1,46 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Grid.ScriptServer +{ + class OpenScript_Main + { + + public static ScriptServerMain SE; + + static void Main(string[] args) + { + // Application is starting + SE = new ScriptServerMain(); + } + + } +} diff --git a/OpenSim/Grid/ScriptServer/Main.cs b/OpenSim/Grid/ScriptServer/Main.cs deleted file mode 100644 index 9f16ea8..0000000 --- a/OpenSim/Grid/ScriptServer/Main.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Grid.ScriptServer -{ - class OpenScript_Main - { - - public static ScriptServer SE; - - static void Main(string[] args) - { - // Application is starting - SE = new ScriptServer(); - } - - } -} diff --git a/OpenSim/Grid/ScriptServer/RegionConnectionManager.cs b/OpenSim/Grid/ScriptServer/RegionConnectionManager.cs deleted file mode 100644 index 6a517e9..0000000 --- a/OpenSim/Grid/ScriptServer/RegionConnectionManager.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Grid.ScriptServer -{ - // Maintains connection and communication to a region - class RegionConnectionManager - { - - public RegionConnectionManager() - { - } - - } -} diff --git a/OpenSim/Grid/ScriptServer/RegionScriptDaemon.cs b/OpenSim/Grid/ScriptServer/RegionScriptDaemon.cs deleted file mode 100644 index 435c09b..0000000 --- a/OpenSim/Grid/ScriptServer/RegionScriptDaemon.cs +++ /dev/null @@ -1,94 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace OpenSim.Grid.ScriptServer -{ - // Waiting for incoming script requests from region - internal class RegionScriptDaemon - { - private Thread listenThread; - - public ScriptServer m_ScriptServer; - public RegionScriptDaemon(ScriptServer scriptServer) - { - m_ScriptServer = scriptServer; - } - ~RegionScriptDaemon() - { - Stop(); - } - - /// - /// Starts listening for region requests - /// - public void Start() - { - // Start listener - Stop(); - listenThread = new Thread(ListenThreadLoop); - listenThread.Name = "listenThread"; - listenThread.IsBackground = true; - listenThread.Start(); - } - /// - /// Stops listening for region requests - /// - public void Stop() - { - // Stop listener, clean up - if (listenThread != null) - { - try - { - if (listenThread.IsAlive) - listenThread.Abort(); - listenThread.Join(1000); // Wait 1 second for thread to shut down - } - catch { } - listenThread = null; - } - } - - private void ListenThreadLoop() - { - // * Listen for requests from regions - // * When a request is received: - // - Authenticate region - // - Authenticate user - // - Have correct scriptengine load script - // ~ ask scriptengines if they will accept script? - // - Add script to shared communication channel towards that region - - } - - } -} diff --git a/OpenSim/Grid/ScriptServer/RegionsManager.cs b/OpenSim/Grid/ScriptServer/RegionsManager.cs deleted file mode 100644 index 0e1fad1..0000000 --- a/OpenSim/Grid/ScriptServer/RegionsManager.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Grid.ScriptServer -{ - // Maintains all regions - class RegionsManager - { - private List Regions = new List(); - - public ScriptServer m_ScriptServer; - public RegionsManager(ScriptServer scriptServer) - { - m_ScriptServer = scriptServer; - } - - } -} diff --git a/OpenSim/Grid/ScriptServer/ScriptEngineInterface.cs b/OpenSim/Grid/ScriptServer/ScriptEngineInterface.cs deleted file mode 100644 index 7440bcb..0000000 --- a/OpenSim/Grid/ScriptServer/ScriptEngineInterface.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using OpenSim.Framework.Console; - -namespace OpenSim.Grid.ScriptServer -{ - public interface ScriptEngineInterface - { - //void InitializeEngine(Scene Sceneworld, LogBase logger); - void Shutdown(); -// void StartScript(string ScriptID, IScriptHost ObjectID); - } -} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptEngineLoader.cs b/OpenSim/Grid/ScriptServer/ScriptEngineLoader.cs deleted file mode 100644 index 1b5dc39..0000000 --- a/OpenSim/Grid/ScriptServer/ScriptEngineLoader.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System; -using System.IO; -using System.Reflection; -using OpenSim.Framework.Console; - -namespace OpenSim.Grid.ScriptServer -{ - public class ScriptEngineLoader - { - private LogBase m_log; - - public ScriptEngineLoader(LogBase logger) - { - m_log = logger; - } - - public ScriptEngineInterface LoadScriptEngine(string EngineName) - { - ScriptEngineInterface ret = null; - try - { - ret = - LoadAndInitAssembly( - Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), - "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); - } - catch (Exception e) - { - m_log.Error("ScriptEngine", - "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + - e.StackTrace.ToString()); - } - return ret; - } - - /// - /// Does actual loading and initialization of script Assembly - /// - /// AppDomain to load script into - /// FileName of script assembly (.dll) - /// - private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) - { - //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); - // Load .Net Assembly (.dll) - // Initialize and return it - - // TODO: Add error handling - - Assembly a; - //try - //{ - - - // Load to default appdomain (temporary) - a = Assembly.LoadFrom(FileName); - // Load to specified appdomain - // TODO: Insert security - //a = FreeAppDomain.Load(FileName); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); - //} - - - //Console.WriteLine("Loading: " + FileName); - //foreach (Type _t in a.GetTypes()) - //{ - // Console.WriteLine("Type: " + _t.ToString()); - //} - - Type t; - //try - //{ - t = a.GetType(NameSpace, true); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); - //} - - ScriptEngineInterface ret; - //try - //{ - ret = (ScriptEngineInterface) Activator.CreateInstance(t); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); - //} - - return ret; - } - } -} - diff --git a/OpenSim/Grid/ScriptServer/ScriptServer.cs b/OpenSim/Grid/ScriptServer/ScriptServer.cs deleted file mode 100644 index 2c26027..0000000 --- a/OpenSim/Grid/ScriptServer/ScriptServer.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Grid.ScriptServer -{ - class ScriptServer - { - public RegionScriptDaemon RegionScriptDaemon; // Listen for incoming from region - public RegionsManager RegionManager; // Handle regions - public ScriptEngineLoader ScriptEngineLoader; // Loads scriptengines - - public ScriptServer() - { - RegionScriptDaemon = new RegionScriptDaemon(this); - RegionManager = new RegionsManager(this); - //ScriptEngineLoader = new ScriptEngineLoader(this); - } - - ~ScriptServer() - { - } - - - - } -} diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs new file mode 100644 index 0000000..6a517e9 --- /dev/null +++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Grid.ScriptServer +{ + // Maintains connection and communication to a region + class RegionConnectionManager + { + + public RegionConnectionManager() + { + } + + } +} diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionScriptDaemon.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionScriptDaemon.cs new file mode 100644 index 0000000..0385693 --- /dev/null +++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionScriptDaemon.cs @@ -0,0 +1,94 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; + +namespace OpenSim.Grid.ScriptServer +{ + // Waiting for incoming script requests from region + internal class RegionScriptDaemon + { + private Thread listenThread; + + public ScriptServerMain m_ScriptServer; + public RegionScriptDaemon(ScriptServerMain scriptServer) + { + m_ScriptServer = scriptServer; + } + ~RegionScriptDaemon() + { + Stop(); + } + + /// + /// Starts listening for region requests + /// + public void Start() + { + // Start listener + Stop(); + listenThread = new Thread(ListenThreadLoop); + listenThread.Name = "listenThread"; + listenThread.IsBackground = true; + listenThread.Start(); + } + /// + /// Stops listening for region requests + /// + public void Stop() + { + // Stop listener, clean up + if (listenThread != null) + { + try + { + if (listenThread.IsAlive) + listenThread.Abort(); + listenThread.Join(1000); // Wait 1 second for thread to shut down + } + catch { } + listenThread = null; + } + } + + private void ListenThreadLoop() + { + // * Listen for requests from regions + // * When a request is received: + // - Authenticate region + // - Authenticate user + // - Have correct scriptengine load script + // ~ ask scriptengines if they will accept script? + // - Add script to shared communication channel towards that region + + } + + } +} diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/RegionsManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/RegionsManager.cs new file mode 100644 index 0000000..eeec92b --- /dev/null +++ b/OpenSim/Grid/ScriptServer/ScriptServer/RegionsManager.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Grid.ScriptServer +{ + // Maintains all regions + class RegionsManager + { + private List Regions = new List(); + + public ScriptServerMain m_ScriptServer; + public RegionsManager(ScriptServerMain scriptServer) + { + m_ScriptServer = scriptServer; + } + + } +} diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineInterface.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineInterface.cs new file mode 100644 index 0000000..7440bcb --- /dev/null +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineInterface.cs @@ -0,0 +1,38 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using OpenSim.Framework.Console; + +namespace OpenSim.Grid.ScriptServer +{ + public interface ScriptEngineInterface + { + //void InitializeEngine(Scene Sceneworld, LogBase logger); + void Shutdown(); +// void StartScript(string ScriptID, IScriptHost ObjectID); + } +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineLoader.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineLoader.cs new file mode 100644 index 0000000..1b5dc39 --- /dev/null +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngine/ScriptEngineLoader.cs @@ -0,0 +1,124 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.IO; +using System.Reflection; +using OpenSim.Framework.Console; + +namespace OpenSim.Grid.ScriptServer +{ + public class ScriptEngineLoader + { + private LogBase m_log; + + public ScriptEngineLoader(LogBase logger) + { + m_log = logger; + } + + public ScriptEngineInterface LoadScriptEngine(string EngineName) + { + ScriptEngineInterface ret = null; + try + { + ret = + LoadAndInitAssembly( + Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), + "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); + } + catch (Exception e) + { + m_log.Error("ScriptEngine", + "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + + e.StackTrace.ToString()); + } + return ret; + } + + /// + /// Does actual loading and initialization of script Assembly + /// + /// AppDomain to load script into + /// FileName of script assembly (.dll) + /// + private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) + { + //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); + // Load .Net Assembly (.dll) + // Initialize and return it + + // TODO: Add error handling + + Assembly a; + //try + //{ + + + // Load to default appdomain (temporary) + a = Assembly.LoadFrom(FileName); + // Load to specified appdomain + // TODO: Insert security + //a = FreeAppDomain.Load(FileName); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); + //} + + + //Console.WriteLine("Loading: " + FileName); + //foreach (Type _t in a.GetTypes()) + //{ + // Console.WriteLine("Type: " + _t.ToString()); + //} + + Type t; + //try + //{ + t = a.GetType(NameSpace, true); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); + //} + + ScriptEngineInterface ret; + //try + //{ + ret = (ScriptEngineInterface) Activator.CreateInstance(t); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); + //} + + return ret; + } + } +} + diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs new file mode 100644 index 0000000..4fce3d6 --- /dev/null +++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using OpenSim.Framework.Console; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Grid.ScriptServer +{ + class ScriptServerMain : conscmd_callback + { + private readonly string m_logFilename = ("region-console.log"); + public RegionScriptDaemon RegionScriptDaemon; // Listen for incoming from region + public RegionsManager RegionManager; // Handle regions + public ScriptEngineLoader ScriptEngineLoader; // Loads scriptengines + private LogBase m_log; + + public ScriptServerMain() + { + m_log = CreateLog(); + + RegionScriptDaemon = new RegionScriptDaemon(this); + RegionManager = new RegionsManager(this); + ScriptEngineLoader = new ScriptEngineLoader(m_log); + } + + ~ScriptServerMain() + { + } + + protected LogBase CreateLog() + { + if (!Directory.Exists(Util.logDir())) + { + Directory.CreateDirectory(Util.logDir()); + } + + return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, false); + } + + public void RunCmd(string command, string[] cmdparams) + { + } + public void Show(string ShowWhat) + { + } + + } +} -- cgit v1.1