changes to pass nini config object to the modules that get

loaded so that they may read out any bits they are interested in
afrisby
Sean Dague 2007-10-19 20:27:34 +00:00
parent aaaa3c6835
commit 139994757c
21 changed files with 1885 additions and 1858 deletions

View File

@ -1,132 +1,133 @@
/*
* 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.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Environment.Interfaces;
using libsecondlife;
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
{
/// <summary>
/// This is the root object for ScriptEngine
/// </summary>
[Serializable]
public class ScriptEngine :IRegionModule
{
internal OpenSim.Region.Environment.Scenes.Scene World;
internal 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
internal AppDomainManager m_AppDomainManager;
internal LSLLongCmdHandler m_LSLLongCmdHandler;
private OpenSim.Framework.Console.LogBase m_log;
public ScriptEngine()
{
//Common.SendToDebug("ScriptEngine Object Initialized");
Common.mySE = this;
}
public LogBase Log
{
get { return m_log; }
}
public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger)
{
World = Sceneworld;
m_log = logger;
Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
//m_logger.Status("ScriptEngine", "InitializeEngine");
// Create all objects we'll be using
m_EventQueueManager = new EventQueueManager(this);
m_EventManager = new EventManager(this);
m_ScriptManager = new ScriptManager(this);
m_AppDomainManager = new AppDomainManager();
m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
// Should we iterate the region for scripts that needs starting?
// Or can we assume we are loaded before anything else so we can use proper events?
}
public void Shutdown()
{
// 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
public void Initialise(Scene scene)
{
this.InitializeEngine(scene, MainLog.Instance);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "LSLScriptingModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
}
}
/*
* 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.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Environment.Interfaces;
using libsecondlife;
using Nini.Config;
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
{
/// <summary>
/// This is the root object for ScriptEngine
/// </summary>
[Serializable]
public class ScriptEngine :IRegionModule
{
internal OpenSim.Region.Environment.Scenes.Scene World;
internal 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
internal AppDomainManager m_AppDomainManager;
internal LSLLongCmdHandler m_LSLLongCmdHandler;
private OpenSim.Framework.Console.LogBase m_log;
public ScriptEngine()
{
//Common.SendToDebug("ScriptEngine Object Initialized");
Common.mySE = this;
}
public LogBase Log
{
get { return m_log; }
}
public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger)
{
World = Sceneworld;
m_log = logger;
Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
//m_logger.Status("ScriptEngine", "InitializeEngine");
// Create all objects we'll be using
m_EventQueueManager = new EventQueueManager(this);
m_EventManager = new EventManager(this);
m_ScriptManager = new ScriptManager(this);
m_AppDomainManager = new AppDomainManager();
m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
// Should we iterate the region for scripts that needs starting?
// Or can we assume we are loaded before anything else so we can use proper events?
}
public void Shutdown()
{
// 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
public void Initialise(Scene scene, IConfigSource config)
{
this.InitializeEngine(scene, MainLog.Instance);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "LSLScriptingModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
}
}

View File

@ -63,6 +63,7 @@ namespace OpenSim
protected ModuleLoader m_moduleLoader;
protected LocalLoginService m_loginService;
private IConfigSource m_config;
protected string m_storageDLL = "OpenSim.DataStore.NullStorage.dll";
@ -89,9 +90,8 @@ namespace OpenSim
public OpenSimMain(IConfigSource configSource)
: base()
{
IConfigSource startupSource = configSource;
string iniFile = startupSource.Configs["Startup"].GetString("inifile", "OpenSim.ini");
string useExecutePathString = startupSource.Configs["Startup"].GetString("useexecutepath", "false").ToLower();
string iniFile = configSource.Configs["Startup"].GetString("inifile", "OpenSim.ini");
string useExecutePathString = configSource.Configs["Startup"].GetString("useexecutepath", "false").ToLower();
bool useExecutePath = false;
if (useExecutePathString == "true" || useExecutePathString == "" || useExecutePathString == "1" || useExecutePathString == "yes")
{
@ -104,46 +104,46 @@ namespace OpenSim
string iniFilePath = Path.Combine(Util.configDir(), iniFile);
if (File.Exists(iniFilePath))
{
startupSource = new IniConfigSource(iniFilePath);
m_config = new IniConfigSource(iniFilePath);
//enable following line, if we want the original config source(normally commandline args) merged with ini file settings.
//in this case we have it so that if both sources have the same named setting, the command line value will overwrite the ini file value.
//(as if someone has bothered to enter a command line arg, we should take notice of it)
startupSource.Merge(configSource);
m_config.Merge(configSource);
}
ReadConfigSettings(startupSource);
ReadConfigSettings();
}
protected void ReadConfigSettings(IConfigSource configSource)
protected void ReadConfigSettings()
{
m_networkServersInfo = new NetworkServersInfo();
m_sandbox = !configSource.Configs["Startup"].GetBoolean("gridmode", false);
m_physicsEngine = configSource.Configs["Startup"].GetString("physics", "basicphysics");
m_silent = configSource.Configs["Startup"].GetBoolean("noverbose", false);
m_permissions = configSource.Configs["Startup"].GetBoolean("serverside_object_permissions", false);
m_sandbox = !m_config.Configs["Startup"].GetBoolean("gridmode", false);
m_physicsEngine = m_config.Configs["Startup"].GetString("physics", "basicphysics");
m_silent = m_config.Configs["Startup"].GetBoolean("noverbose", false);
m_permissions = m_config.Configs["Startup"].GetBoolean("serverside_object_permissions", false);
m_storageDLL = configSource.Configs["Startup"].GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll");
m_storageDLL = m_config.Configs["Startup"].GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll");
m_startupCommandsFile = configSource.Configs["Startup"].GetString("startup_console_commands_file", "");
m_shutdownCommandsFile = configSource.Configs["Startup"].GetString("shutdown_console_commands_file", "");
m_startupCommandsFile = m_config.Configs["Startup"].GetString("startup_console_commands_file", "");
m_shutdownCommandsFile = m_config.Configs["Startup"].GetString("shutdown_console_commands_file", "");
m_scriptEngine = configSource.Configs["Startup"].GetString("script_engine", "DotNetEngine");
m_scriptEngine = m_config.Configs["Startup"].GetString("script_engine", "DotNetEngine");
m_assetStorage = configSource.Configs["Startup"].GetString("asset_database", "db4o");
m_assetStorage = m_config.Configs["Startup"].GetString("asset_database", "db4o");
configSource.Configs["Startup"].GetBoolean("default_modules", true);
configSource.Configs["Startup"].GetBoolean("default_shared_modules", true);
configSource.Configs["Startup"].GetString("except_modules", "");
configSource.Configs["Startup"].GetString("except_shared_modules", "");
m_config.Configs["Startup"].GetBoolean("default_modules", true);
m_config.Configs["Startup"].GetBoolean("default_shared_modules", true);
m_config.Configs["Startup"].GetString("except_modules", "");
m_config.Configs["Startup"].GetString("except_shared_modules", "");
standaloneAuthenticate = configSource.Configs["StandAlone"].GetBoolean("accounts_authenticate", false);
standaloneWelcomeMessage = configSource.Configs["StandAlone"].GetString("welcome_message", "Welcome to OpenSim");
standaloneInventoryPlugin = configSource.Configs["StandAlone"].GetString("inventory_plugin", "OpenSim.Framework.Data.SQLite.dll");
standaloneUserPlugin = configSource.Configs["StandAlone"].GetString("userDatabase_plugin", "OpenSim.Framework.Data.DB4o.dll");
standaloneAssetPlugin = configSource.Configs["StandAlone"].GetString("asset_plugin", "OpenSim.Framework.Data.SQLite.dll");
m_networkServersInfo.loadFromConfiguration(configSource);
standaloneAuthenticate = m_config.Configs["StandAlone"].GetBoolean("accounts_authenticate", false);
standaloneWelcomeMessage = m_config.Configs["StandAlone"].GetString("welcome_message", "Welcome to OpenSim");
standaloneInventoryPlugin = m_config.Configs["StandAlone"].GetString("inventory_plugin", "OpenSim.Framework.Data.SQLite.dll");
standaloneUserPlugin = m_config.Configs["StandAlone"].GetString("userDatabase_plugin", "OpenSim.Framework.Data.DB4o.dll");
standaloneAssetPlugin = m_config.Configs["StandAlone"].GetString("asset_plugin", "OpenSim.Framework.Data.SQLite.dll");
m_networkServersInfo.loadFromConfiguration(m_config);
}
@ -207,7 +207,7 @@ namespace OpenSim
configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
}
m_moduleLoader = new ModuleLoader( m_log );
m_moduleLoader = new ModuleLoader( m_log, m_config );
MainLog.Instance.Verbose("Loading Shared Modules");
m_moduleLoader.LoadDefaultSharedModules();

View File

@ -27,12 +27,13 @@
*/
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Interfaces
{
public interface IRegionModule
{
void Initialise(Scene scene);
void Initialise(Scene scene, IConfigSource source);
void PostInitialise();
void Close();
string Name { get; }

View File

@ -1,202 +1,205 @@
/*
* 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.IO;
using System.Reflection;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment
{
public class ModuleLoader
{
public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
public List<IRegionModule> LoadedModules = new List<IRegionModule>();
public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>();
private readonly LogBase m_log;
public ModuleLoader(LogBase log)
{
m_log = log;
}
public void PickupModules(Scene scene, string moduleDir)
{
DirectoryInfo dir = new DirectoryInfo(moduleDir);
foreach (FileInfo fileInfo in dir.GetFiles("*.dll"))
{
LoadRegionModules(fileInfo.FullName, scene);
}
}
public void LoadDefaultSharedModules()
{
DynamicTextureModule dynamicModule = new DynamicTextureModule();
LoadedSharedModules.Add(dynamicModule.Name, dynamicModule);
}
public void InitialiseSharedModules(Scene scene)
{
foreach (IRegionModule module in LoadedSharedModules.Values)
{
module.Initialise(scene);
scene.AddModule(module.Name, module); //should be doing this?
}
}
public void InitializeModule(IRegionModule module, Scene scene)
{
module.Initialise(scene);
scene.AddModule(module.Name, module);
LoadedModules.Add(module);
}
/// <summary>
/// Loads/initialises a Module instance that can be used by mutliple Regions
/// </summary>
/// <param name="dllName"></param>
/// <param name="moduleName"></param>
/// <param name="scene"></param>
public void LoadSharedModule(string dllName, string moduleName)
{
IRegionModule module = LoadModule(dllName, moduleName);
if (module != null)
{
LoadedSharedModules.Add(module.Name, module);
}
}
public void LoadRegionModules(string dllName, Scene scene)
{
IRegionModule[] modules = LoadModules(dllName);
if (modules.Length > 0)
{
m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName );
foreach (IRegionModule module in modules)
{
m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name);
InitializeModule(module, scene);
}
}
}
public void LoadRegionModule(string dllName, string moduleName, Scene scene)
{
IRegionModule module = LoadModule(dllName, moduleName);
if (module != null)
{
InitializeModule(module, scene);
}
}
/// <summary>
/// Loads a external Module (if not already loaded) and creates a new instance of it.
/// </summary>
/// <param name="dllName"></param>
/// <param name="moduleName"></param>
/// <param name="scene"></param>
public IRegionModule LoadModule(string dllName, string moduleName)
{
IRegionModule[] modules = LoadModules(dllName);
foreach (IRegionModule module in modules)
{
if ((module != null) && (module.Name == moduleName))
{
return module;
}
}
return null;
}
public IRegionModule[] LoadModules(string dllName)
{
List<IRegionModule> modules = new List<IRegionModule>();
Assembly pluginAssembly;
if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly ))
{
try
{
pluginAssembly = Assembly.LoadFrom(dllName);
LoadedAssemblys.Add(dllName, pluginAssembly);
}
catch( BadImageFormatException e )
{
m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName );
}
}
if (pluginAssembly != null)
{
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
if( pluginType.GetInterface("IRegionModule") != null )
{
modules.Add((IRegionModule) Activator.CreateInstance(pluginType));
}
}
}
}
}
return modules.ToArray();
}
public void PostInitialise()
{
foreach (IRegionModule module in LoadedSharedModules.Values)
{
module.PostInitialise();
}
foreach (IRegionModule module in LoadedModules)
{
module.PostInitialise();
}
}
public void ClearCache()
{
LoadedAssemblys.Clear();
}
}
}
/*
* 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.IO;
using System.Reflection;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment
{
public class ModuleLoader
{
public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>();
public List<IRegionModule> LoadedModules = new List<IRegionModule>();
public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>();
private readonly LogBase m_log;
private IConfigSource m_config;
public ModuleLoader(LogBase log, IConfigSource config)
{
m_log = log;
m_config = config;
}
public void PickupModules(Scene scene, string moduleDir)
{
DirectoryInfo dir = new DirectoryInfo(moduleDir);
foreach (FileInfo fileInfo in dir.GetFiles("*.dll"))
{
LoadRegionModules(fileInfo.FullName, scene);
}
}
public void LoadDefaultSharedModules()
{
DynamicTextureModule dynamicModule = new DynamicTextureModule();
LoadedSharedModules.Add(dynamicModule.Name, dynamicModule);
}
public void InitialiseSharedModules(Scene scene)
{
foreach (IRegionModule module in LoadedSharedModules.Values)
{
module.Initialise(scene, m_config);
scene.AddModule(module.Name, module); //should be doing this?
}
}
public void InitializeModule(IRegionModule module, Scene scene)
{
module.Initialise(scene, m_config);
scene.AddModule(module.Name, module);
LoadedModules.Add(module);
}
/// <summary>
/// Loads/initialises a Module instance that can be used by mutliple Regions
/// </summary>
/// <param name="dllName"></param>
/// <param name="moduleName"></param>
/// <param name="scene"></param>
public void LoadSharedModule(string dllName, string moduleName)
{
IRegionModule module = LoadModule(dllName, moduleName);
if (module != null)
{
LoadedSharedModules.Add(module.Name, module);
}
}
public void LoadRegionModules(string dllName, Scene scene)
{
IRegionModule[] modules = LoadModules(dllName);
if (modules.Length > 0)
{
m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName );
foreach (IRegionModule module in modules)
{
m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name);
InitializeModule(module, scene);
}
}
}
public void LoadRegionModule(string dllName, string moduleName, Scene scene)
{
IRegionModule module = LoadModule(dllName, moduleName);
if (module != null)
{
InitializeModule(module, scene);
}
}
/// <summary>
/// Loads a external Module (if not already loaded) and creates a new instance of it.
/// </summary>
/// <param name="dllName"></param>
/// <param name="moduleName"></param>
/// <param name="scene"></param>
public IRegionModule LoadModule(string dllName, string moduleName)
{
IRegionModule[] modules = LoadModules(dllName);
foreach (IRegionModule module in modules)
{
if ((module != null) && (module.Name == moduleName))
{
return module;
}
}
return null;
}
public IRegionModule[] LoadModules(string dllName)
{
List<IRegionModule> modules = new List<IRegionModule>();
Assembly pluginAssembly;
if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly ))
{
try
{
pluginAssembly = Assembly.LoadFrom(dllName);
LoadedAssemblys.Add(dllName, pluginAssembly);
}
catch( BadImageFormatException e )
{
m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName );
}
}
if (pluginAssembly != null)
{
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
if( pluginType.GetInterface("IRegionModule") != null )
{
modules.Add((IRegionModule) Activator.CreateInstance(pluginType));
}
}
}
}
}
return modules.ToArray();
}
public void PostInitialise()
{
foreach (IRegionModule module in LoadedSharedModules.Values)
{
module.PostInitialise();
}
foreach (IRegionModule module in LoadedModules)
{
module.PostInitialise();
}
}
public void ClearCache()
{
LoadedAssemblys.Clear();
}
}
}

View File

@ -29,6 +29,7 @@
using OpenSim.Framework.Interfaces;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
@ -40,7 +41,7 @@ namespace OpenSim.Region.Environment.Modules
{
}
public void Initialise(Scene scene)
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;

View File

@ -1,93 +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 libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class AvatarProfilesModule : IRegionModule
{
private Scene m_scene;
public AvatarProfilesModule()
{
}
public void Initialise(Scene scene)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "AvatarProfilesModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
client.OnRequestAvatarProperties += RequestAvatarProperty;
}
public void RemoveClient(IClientAPI client)
{
client.OnRequestAvatarProperties -= RequestAvatarProperty;
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="avatarID"></param>
public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID)
{
string about = "OpenSim crash test dummy";
string bornOn = "Before now";
string flAbout = "First life? What is one of those? OpenSim is my life!";
LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000");
remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "",
partner);
}
}
}
/*
* 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 libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class AvatarProfilesModule : IRegionModule
{
private Scene m_scene;
public AvatarProfilesModule()
{
}
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "AvatarProfilesModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
client.OnRequestAvatarProperties += RequestAvatarProperty;
}
public void RemoveClient(IClientAPI client)
{
client.OnRequestAvatarProperties -= RequestAvatarProperty;
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="avatarID"></param>
public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID)
{
string about = "OpenSim crash test dummy";
string bornOn = "Before now";
string flAbout = "First life? What is one of those? OpenSim is my life!";
LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000");
remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "",
partner);
}
}
}

View File

@ -1,242 +1,243 @@
/*
* 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.Net.Sockets;
using System.Threading;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Utilities;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class ChatModule : IRegionModule, ISimChat
{
private Scene m_scene;
private string m_server = "irc2.choopa.net";
// private int m_port = 6668;
//private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private string m_nick = "OSimBot";
private string m_channel = "#opensim";
// private NetworkStream m_stream;
private TcpClient m_irc;
private StreamWriter m_ircWriter;
private StreamReader m_ircReader;
// private Thread pingSender;
// private Thread listener;
private bool connected = false;
public ChatModule()
{
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
m_irc = null;
m_ircWriter = null;
m_ircReader = null;
}
public void Initialise(Scene scene)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
m_scene.RegisterModuleInterface<ISimChat>(this);
}
public void PostInitialise()
{
/*
try
{
m_irc = new TcpClient(m_server, m_port);
m_stream = m_irc.GetStream();
m_ircReader = new StreamReader(m_stream);
m_ircWriter = new StreamWriter(m_stream);
pingSender = new Thread(new ThreadStart(this.PingRun));
pingSender.Start();
listener = new Thread(new ThreadStart(this.ListenerRun));
listener.Start();
m_ircWriter.WriteLine(m_user);
m_ircWriter.Flush();
m_ircWriter.WriteLine("NICK " + m_nick);
m_ircWriter.Flush();
m_ircWriter.WriteLine("JOIN " + m_channel);
m_ircWriter.Flush();
connected = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
*/
}
public void Close()
{
m_ircWriter.Close();
m_ircReader.Close();
m_irc.Close();
}
public string Name
{
get { return "ChatModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
client.OnChatFromViewer += SimChat;
}
public void PingRun()
{
while (true)
{
m_ircWriter.WriteLine("PING :" + m_server);
m_ircWriter.Flush();
Thread.Sleep(15000);
}
}
public void ListenerRun()
{
string inputLine;
LLVector3 pos = new LLVector3(128, 128, 20);
while (true)
{
while ((inputLine = m_ircReader.ReadLine()) != null)
{
Console.WriteLine(inputLine);
if (inputLine.Contains(m_channel))
{
string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
m_scene.Broadcast(delegate(IClientAPI client)
{
client.SendChatMessage(
Helpers.StringToField(mess), 255, pos, "IRC:",
LLUUID.Zero);
});
}
}
}
}
public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName,
LLUUID fromAgentID)
{
ScenePresence avatar = null;
avatar = m_scene.GetScenePresence(fromAgentID);
if (avatar != null)
{
fromPos = avatar.AbsolutePosition;
fromName = avatar.Firstname + " " + avatar.Lastname;
avatar = null;
}
if (connected)
{
m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " +
Util.FieldToString(message));
m_ircWriter.Flush();
}
if (channel == 0)
{
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
int dis = -1000;
//err ??? the following code seems to be request a scenePresence when it already has a ref to it
avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId);
if (avatar != null)
{
dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);
}
switch (type)
{
case 0: // Whisper
if ((dis < 10) && (dis > -10))
{
//should change so the message is sent through the avatar rather than direct to the ClientView
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case 1: // Say
if ((dis < 30) && (dis > -30))
{
//Console.WriteLine("sending chat");
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case 2: // Shout
if ((dis < 100) && (dis > -100))
{
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case 0xff: // Broadcast
presence.ControllingClient.SendChatMessage(message, type,
fromPos,
fromName,
fromAgentID);
break;
}
});
}
}
}
}
/*
* 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.Net.Sockets;
using System.Threading;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Utilities;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class ChatModule : IRegionModule, ISimChat
{
private Scene m_scene;
private string m_server = "irc2.choopa.net";
// private int m_port = 6668;
//private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private string m_nick = "OSimBot";
private string m_channel = "#opensim";
// private NetworkStream m_stream;
private TcpClient m_irc;
private StreamWriter m_ircWriter;
private StreamReader m_ircReader;
// private Thread pingSender;
// private Thread listener;
private bool connected = false;
public ChatModule()
{
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
m_irc = null;
m_ircWriter = null;
m_ircReader = null;
}
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
m_scene.RegisterModuleInterface<ISimChat>(this);
}
public void PostInitialise()
{
/*
try
{
m_irc = new TcpClient(m_server, m_port);
m_stream = m_irc.GetStream();
m_ircReader = new StreamReader(m_stream);
m_ircWriter = new StreamWriter(m_stream);
pingSender = new Thread(new ThreadStart(this.PingRun));
pingSender.Start();
listener = new Thread(new ThreadStart(this.ListenerRun));
listener.Start();
m_ircWriter.WriteLine(m_user);
m_ircWriter.Flush();
m_ircWriter.WriteLine("NICK " + m_nick);
m_ircWriter.Flush();
m_ircWriter.WriteLine("JOIN " + m_channel);
m_ircWriter.Flush();
connected = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
*/
}
public void Close()
{
m_ircWriter.Close();
m_ircReader.Close();
m_irc.Close();
}
public string Name
{
get { return "ChatModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
client.OnChatFromViewer += SimChat;
}
public void PingRun()
{
while (true)
{
m_ircWriter.WriteLine("PING :" + m_server);
m_ircWriter.Flush();
Thread.Sleep(15000);
}
}
public void ListenerRun()
{
string inputLine;
LLVector3 pos = new LLVector3(128, 128, 20);
while (true)
{
while ((inputLine = m_ircReader.ReadLine()) != null)
{
Console.WriteLine(inputLine);
if (inputLine.Contains(m_channel))
{
string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
m_scene.Broadcast(delegate(IClientAPI client)
{
client.SendChatMessage(
Helpers.StringToField(mess), 255, pos, "IRC:",
LLUUID.Zero);
});
}
}
}
}
public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName,
LLUUID fromAgentID)
{
ScenePresence avatar = null;
avatar = m_scene.GetScenePresence(fromAgentID);
if (avatar != null)
{
fromPos = avatar.AbsolutePosition;
fromName = avatar.Firstname + " " + avatar.Lastname;
avatar = null;
}
if (connected)
{
m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " +
Util.FieldToString(message));
m_ircWriter.Flush();
}
if (channel == 0)
{
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
int dis = -1000;
//err ??? the following code seems to be request a scenePresence when it already has a ref to it
avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId);
if (avatar != null)
{
dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);
}
switch (type)
{
case 0: // Whisper
if ((dis < 10) && (dis > -10))
{
//should change so the message is sent through the avatar rather than direct to the ClientView
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case 1: // Say
if ((dis < 30) && (dis > -30))
{
//Console.WriteLine("sending chat");
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case 2: // Shout
if ((dis < 100) && (dis > -100))
{
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case 0xff: // Broadcast
presence.ControllingClient.SendChatMessage(message, type,
fromPos,
fromName,
fromAgentID);
break;
}
});
}
}
}
}

View File

@ -1,190 +1,191 @@
/*
* 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 libsecondlife;
using OpenSim.Framework.Types;
using OpenSim.Framework.Utilities;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
{
private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
private Dictionary<string, IDynamicTextureRender> RenderPlugins =
new Dictionary<string, IDynamicTextureRender>();
private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
public void Initialise(Scene scene)
{
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
scene.RegisterModuleInterface<IDynamicTextureManager>(this);
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "DynamicTextureModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
public void RegisterRender(string handleType, IDynamicTextureRender render)
{
if (!RenderPlugins.ContainsKey(handleType))
{
RenderPlugins.Add(handleType, render);
}
}
public void ReturnData(LLUUID id, byte[] data)
{
if (Updaters.ContainsKey(id))
{
DynamicTextureUpdater updater = Updaters[id];
if (RegisteredScenes.ContainsKey(updater.SimUUID))
{
Scene scene = RegisteredScenes[updater.SimUUID];
updater.DataReceived(data, scene);
}
}
}
public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url,
string extraParams, int updateTimer)
{
if (RenderPlugins.ContainsKey(contentType))
{
//Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType);
DynamicTextureUpdater updater = new DynamicTextureUpdater();
updater.SimUUID = simID;
updater.PrimID = primID;
updater.ContentType = contentType;
updater.Url = url;
updater.UpdateTimer = updateTimer;
updater.UpdaterID = LLUUID.Random();
updater.Params = extraParams;
if (!Updaters.ContainsKey(updater.UpdaterID))
{
Updaters.Add(updater.UpdaterID, updater);
}
RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
return updater.UpdaterID;
}
return LLUUID.Zero;
}
public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data,
string extraParams, int updateTimer)
{
if (RenderPlugins.ContainsKey(contentType))
{
DynamicTextureUpdater updater = new DynamicTextureUpdater();
updater.SimUUID = simID;
updater.PrimID = primID;
updater.ContentType = contentType;
updater.BodyData = data;
updater.UpdateTimer = updateTimer;
updater.UpdaterID = LLUUID.Random();
updater.Params = extraParams;
if (!Updaters.ContainsKey(updater.UpdaterID))
{
Updaters.Add(updater.UpdaterID, updater);
}
RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
return updater.UpdaterID;
}
return LLUUID.Zero;
}
public class DynamicTextureUpdater
{
public LLUUID SimUUID;
public LLUUID UpdaterID;
public string ContentType;
public string Url;
public string BodyData;
public LLUUID PrimID;
public int UpdateTimer;
public LLUUID LastAssetID;
public string Params;
public DynamicTextureUpdater()
{
LastAssetID = LLUUID.Zero;
UpdateTimer = 0;
BodyData = null;
}
public void DataReceived(byte[] data, Scene scene)
{
//TODO delete the last asset(data), if it was a dynamic texture
byte[] assetData = new byte[data.Length];
Array.Copy(data, assetData, data.Length);
AssetBase asset = new AssetBase();
asset.FullID = LLUUID.Random();
asset.Data = assetData;
asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000);
asset.Type = 0;
asset.Description = "dynamic image";
asset.Local = false;
asset.Temporary = false;
scene.commsManager.AssetCache.AddAsset(asset);
LastAssetID = asset.FullID;
SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes();
part.ScheduleFullUpdate();
}
}
}
}
/*
* 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 libsecondlife;
using OpenSim.Framework.Types;
using OpenSim.Framework.Utilities;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
{
private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
private Dictionary<string, IDynamicTextureRender> RenderPlugins =
new Dictionary<string, IDynamicTextureRender>();
private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
public void Initialise(Scene scene, IConfigSource config)
{
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
scene.RegisterModuleInterface<IDynamicTextureManager>(this);
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "DynamicTextureModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
public void RegisterRender(string handleType, IDynamicTextureRender render)
{
if (!RenderPlugins.ContainsKey(handleType))
{
RenderPlugins.Add(handleType, render);
}
}
public void ReturnData(LLUUID id, byte[] data)
{
if (Updaters.ContainsKey(id))
{
DynamicTextureUpdater updater = Updaters[id];
if (RegisteredScenes.ContainsKey(updater.SimUUID))
{
Scene scene = RegisteredScenes[updater.SimUUID];
updater.DataReceived(data, scene);
}
}
}
public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url,
string extraParams, int updateTimer)
{
if (RenderPlugins.ContainsKey(contentType))
{
//Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType);
DynamicTextureUpdater updater = new DynamicTextureUpdater();
updater.SimUUID = simID;
updater.PrimID = primID;
updater.ContentType = contentType;
updater.Url = url;
updater.UpdateTimer = updateTimer;
updater.UpdaterID = LLUUID.Random();
updater.Params = extraParams;
if (!Updaters.ContainsKey(updater.UpdaterID))
{
Updaters.Add(updater.UpdaterID, updater);
}
RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
return updater.UpdaterID;
}
return LLUUID.Zero;
}
public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data,
string extraParams, int updateTimer)
{
if (RenderPlugins.ContainsKey(contentType))
{
DynamicTextureUpdater updater = new DynamicTextureUpdater();
updater.SimUUID = simID;
updater.PrimID = primID;
updater.ContentType = contentType;
updater.BodyData = data;
updater.UpdateTimer = updateTimer;
updater.UpdaterID = LLUUID.Random();
updater.Params = extraParams;
if (!Updaters.ContainsKey(updater.UpdaterID))
{
Updaters.Add(updater.UpdaterID, updater);
}
RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
return updater.UpdaterID;
}
return LLUUID.Zero;
}
public class DynamicTextureUpdater
{
public LLUUID SimUUID;
public LLUUID UpdaterID;
public string ContentType;
public string Url;
public string BodyData;
public LLUUID PrimID;
public int UpdateTimer;
public LLUUID LastAssetID;
public string Params;
public DynamicTextureUpdater()
{
LastAssetID = LLUUID.Zero;
UpdateTimer = 0;
BodyData = null;
}
public void DataReceived(byte[] data, Scene scene)
{
//TODO delete the last asset(data), if it was a dynamic texture
byte[] assetData = new byte[data.Length];
Array.Copy(data, assetData, data.Length);
AssetBase asset = new AssetBase();
asset.FullID = LLUUID.Random();
asset.Data = assetData;
asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000);
asset.Type = 0;
asset.Description = "dynamic image";
asset.Local = false;
asset.Temporary = false;
scene.commsManager.AssetCache.AddAsset(asset);
LastAssetID = asset.FullID;
SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes();
part.ScheduleFullUpdate();
}
}
}
}

View File

@ -1,61 +1,62 @@
/*
* 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.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class FriendsModule : IRegionModule
{
private Scene m_scene;
public void Initialise(Scene scene)
{
m_scene = scene;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "FriendsModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
}
}
/*
* 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.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class FriendsModule : IRegionModule
{
private Scene m_scene;
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "FriendsModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
}
}

View File

@ -1,61 +1,62 @@
/*
* 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.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class GroupsModule : IRegionModule
{
private Scene m_scene;
public void Initialise(Scene scene)
{
m_scene = scene;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "GroupsModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
}
}
/*
* 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.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class GroupsModule : IRegionModule
{
private Scene m_scene;
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "GroupsModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
}
}

View File

@ -1,100 +1,101 @@
/*
* 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.Collections.Generic;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Console;
namespace OpenSim.Region.Environment.Modules
{
public class InstantMessageModule : IRegionModule
{
private List<Scene> m_scenes = new List<Scene>();
private LogBase m_log;
public void Initialise(Scene scene)
{
if (!m_scenes.Contains(scene))
{
m_scenes.Add(scene);
scene.EventManager.OnNewClient += OnNewClient;
m_log = OpenSim.Framework.Console.MainLog.Instance;
}
}
void OnNewClient(OpenSim.Framework.Interfaces.IClientAPI client)
{
client.OnInstantMessage += OnInstantMessage;
}
void OnInstantMessage(libsecondlife.LLUUID fromAgentID,
libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID,
libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog)
{
// TODO: Remove after debugging. Privacy implications.
m_log.Verbose("IM",fromAgentName + ": " + message);
foreach (Scene m_scene in m_scenes)
{
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
{
// Local Message
ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID];
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp);
// Message sent
return;
}
}
// Still here, try send via Grid
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "InstantMessageModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
}
}
/*
* 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.Collections.Generic;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Console;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class InstantMessageModule : IRegionModule
{
private List<Scene> m_scenes = new List<Scene>();
private LogBase m_log;
public void Initialise(Scene scene, IConfigSource config)
{
if (!m_scenes.Contains(scene))
{
m_scenes.Add(scene);
scene.EventManager.OnNewClient += OnNewClient;
m_log = OpenSim.Framework.Console.MainLog.Instance;
}
}
void OnNewClient(OpenSim.Framework.Interfaces.IClientAPI client)
{
client.OnInstantMessage += OnInstantMessage;
}
void OnInstantMessage(libsecondlife.LLUUID fromAgentID,
libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID,
libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog)
{
// TODO: Remove after debugging. Privacy implications.
m_log.Verbose("IM",fromAgentName + ": " + message);
foreach (Scene m_scene in m_scenes)
{
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
{
// Local Message
ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID];
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp);
// Message sent
return;
}
}
// Still here, try send via Grid
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "InstantMessageModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
}
}

View File

@ -1,61 +1,62 @@
/*
* 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.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class InventoryModule : IRegionModule
{
private Scene m_scene;
public void Initialise(Scene scene)
{
m_scene = scene;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "InventoryModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
}
}
/*
* 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.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class InventoryModule : IRegionModule
{
private Scene m_scene;
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "InventoryModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
}
}

View File

@ -1,123 +1,124 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Drawing;
using libsecondlife;
using OpenJPEGNet;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules
{
public class LoadImageURLModule : IRegionModule , IDynamicTextureRender
{
private string m_name = "LoadImageURL";
private IDynamicTextureManager m_textureManager;
private Scene m_scene;
public void Initialise(Scene scene)
{
if (m_scene == null)
{
m_scene = scene;
}
}
public void PostInitialise()
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
m_textureManager.RegisterRender(GetContentType(), this);
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
public string GetName()
{
return m_name;
}
public string GetContentType()
{
return ("image");
}
public bool SupportsAsynchronous()
{
return true;
}
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
}
public byte[] ConvertStream(Stream data, string extraParams)
{
return null;
}
public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
{
MakeHttpRequest(url, id);
return true;
}
public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
{
return false;
}
private void MakeHttpRequest(string url, LLUUID requestID)
{
WebRequest request = HttpWebRequest.Create(url);
RequestState state = new RequestState((HttpWebRequest)request, requestID);
IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state);
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
state.TimeOfRequest = (int)t.TotalSeconds;
}
private void HttpRequestReturn(IAsyncResult result)
{
RequestState state = (RequestState)result.AsyncState;
WebRequest request = (WebRequest)state.Request;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
if (response.StatusCode == HttpStatusCode.OK)
{
Bitmap image = new Bitmap(response.GetResponseStream());
Bitmap resize = new Bitmap(image, new Size(512, 512));
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
m_textureManager.ReturnData(state.RequestID, imageJ2000);
}
}
public class RequestState
{
public HttpWebRequest Request = null;
public LLUUID RequestID = LLUUID.Zero;
public int TimeOfRequest = 0;
public RequestState(HttpWebRequest request, LLUUID requestID)
{
Request = request;
RequestID = requestID;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Drawing;
using libsecondlife;
using OpenJPEGNet;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class LoadImageURLModule : IRegionModule , IDynamicTextureRender
{
private string m_name = "LoadImageURL";
private IDynamicTextureManager m_textureManager;
private Scene m_scene;
public void Initialise(Scene scene, IConfigSource config)
{
if (m_scene == null)
{
m_scene = scene;
}
}
public void PostInitialise()
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
m_textureManager.RegisterRender(GetContentType(), this);
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
public string GetName()
{
return m_name;
}
public string GetContentType()
{
return ("image");
}
public bool SupportsAsynchronous()
{
return true;
}
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
}
public byte[] ConvertStream(Stream data, string extraParams)
{
return null;
}
public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
{
MakeHttpRequest(url, id);
return true;
}
public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
{
return false;
}
private void MakeHttpRequest(string url, LLUUID requestID)
{
WebRequest request = HttpWebRequest.Create(url);
RequestState state = new RequestState((HttpWebRequest)request, requestID);
IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state);
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
state.TimeOfRequest = (int)t.TotalSeconds;
}
private void HttpRequestReturn(IAsyncResult result)
{
RequestState state = (RequestState)result.AsyncState;
WebRequest request = (WebRequest)state.Request;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
if (response.StatusCode == HttpStatusCode.OK)
{
Bitmap image = new Bitmap(response.GetResponseStream());
Bitmap resize = new Bitmap(image, new Size(512, 512));
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
m_textureManager.ReturnData(state.RequestID, imageJ2000);
}
}
public class RequestState
{
public HttpWebRequest Request = null;
public LLUUID RequestID = LLUUID.Zero;
public int TimeOfRequest = 0;
public RequestState(HttpWebRequest request, LLUUID requestID)
{
Request = request;
RequestID = requestID;
}
}
}
}

View File

@ -1,76 +1,77 @@
/*
* 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 libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class TextureDownloadModule : IRegionModule
{
private Scene m_scene;
public TextureDownloadModule()
{
}
public void Initialise(Scene scene)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "TextureDownloadModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
}
public void TextureAssetCallback(LLUUID texture, byte[] data)
{
}
}
}
/*
* 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 libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class TextureDownloadModule : IRegionModule
{
private Scene m_scene;
public TextureDownloadModule()
{
}
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "TextureDownloadModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
}
public void TextureAssetCallback(LLUUID texture, byte[] data)
{
}
}
}

View File

@ -40,6 +40,7 @@ using OpenSim.Framework.Servers;
using Nwc.XmlRpc;
using System.Collections;
using System.Collections.Generic;
using Nini.Config;
/*****************************************************
*
@ -84,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules
{
}
public void Initialise(Scene scene)
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;

View File

@ -39,6 +39,7 @@ using OpenSim.Framework.Servers;
using Nwc.XmlRpc;
using System.Collections;
using System.Collections.Generic;
using Nini.Config;
/*****************************************************
*
@ -93,7 +94,7 @@ namespace OpenSim.Region.Environment.Modules
{
}
public void Initialise(Scene scene)
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;

View File

@ -1,201 +1,202 @@
/*
* 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 libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules
{
public class XferModule : IRegionModule, IXfer
{
public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
private Scene m_scene;
public XferModule()
{
}
public void Initialise(Scene scene)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
m_scene.RegisterModuleInterface<IXfer>(this);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "XferModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
client.OnRequestXfer += RequestXfer;
client.OnConfirmXfer += AckPacket;
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="xferID"></param>
/// <param name="fileName"></param>
public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
{
lock (NewFiles)
{
if (NewFiles.ContainsKey(fileName))
{
if (!Transfers.ContainsKey(xferID))
{
byte[] fileData = NewFiles[fileName];
XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
Transfers.Add(xferID, transaction);
NewFiles.Remove(fileName);
transaction.StartSend();
}
}
}
}
public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet)
{
if (Transfers.ContainsKey(xferID))
{
Transfers[xferID].AckPacket(packet);
}
}
public bool AddNewFile(string fileName, byte[] data)
{
lock (NewFiles)
{
if (NewFiles.ContainsKey(fileName))
{
NewFiles[fileName] = data;
}
else
{
NewFiles.Add(fileName, data);
}
}
return true;
}
public class XferDownLoad
{
public byte[] Data = new byte[0];
public string FileName = "";
public ulong XferID = 0;
public int DataPointer = 0;
public uint Packet = 0;
public IClientAPI Client;
public uint Serial = 1;
private bool complete = false;
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
{
FileName = fileName;
Data = data;
XferID = xferID;
Client = client;
}
public XferDownLoad()
{
}
public void StartSend()
{
if (Data.Length < 1000)
{
// for now (testing ) we only support files under 1000 bytes
byte[] transferData = new byte[Data.Length + 4];
Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
Array.Copy(Data, 0, transferData, 4, Data.Length);
Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
complete = true;
}
else
{
byte[] transferData = new byte[1000 + 4];
Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
Array.Copy(Data, 0, transferData, 4, 1000);
Client.SendXferPacket(XferID, 0, transferData);
Packet++;
DataPointer = 1000;
}
}
public void AckPacket(uint packet)
{
if (!complete)
{
if ((Data.Length - DataPointer) > 1000)
{
byte[] transferData = new byte[1000];
Array.Copy(Data, DataPointer, transferData, 0, 1000);
Client.SendXferPacket(XferID, Packet, transferData);
Packet++;
DataPointer += 1000;
}
else
{
byte[] transferData = new byte[Data.Length - DataPointer];
Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer);
uint endPacket = Packet |= (uint) 0x80000000;
Client.SendXferPacket(XferID, endPacket, transferData);
Packet++;
DataPointer += (Data.Length - DataPointer);
complete = true;
}
}
}
}
}
}
/*
* 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 libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using Nini.Config;
namespace OpenSim.Region.Environment.Modules
{
public class XferModule : IRegionModule, IXfer
{
public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
private Scene m_scene;
public XferModule()
{
}
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
m_scene.RegisterModuleInterface<IXfer>(this);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "XferModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public void NewClient(IClientAPI client)
{
client.OnRequestXfer += RequestXfer;
client.OnConfirmXfer += AckPacket;
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="xferID"></param>
/// <param name="fileName"></param>
public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
{
lock (NewFiles)
{
if (NewFiles.ContainsKey(fileName))
{
if (!Transfers.ContainsKey(xferID))
{
byte[] fileData = NewFiles[fileName];
XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
Transfers.Add(xferID, transaction);
NewFiles.Remove(fileName);
transaction.StartSend();
}
}
}
}
public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet)
{
if (Transfers.ContainsKey(xferID))
{
Transfers[xferID].AckPacket(packet);
}
}
public bool AddNewFile(string fileName, byte[] data)
{
lock (NewFiles)
{
if (NewFiles.ContainsKey(fileName))
{
NewFiles[fileName] = data;
}
else
{
NewFiles.Add(fileName, data);
}
}
return true;
}
public class XferDownLoad
{
public byte[] Data = new byte[0];
public string FileName = "";
public ulong XferID = 0;
public int DataPointer = 0;
public uint Packet = 0;
public IClientAPI Client;
public uint Serial = 1;
private bool complete = false;
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
{
FileName = fileName;
Data = data;
XferID = xferID;
Client = client;
}
public XferDownLoad()
{
}
public void StartSend()
{
if (Data.Length < 1000)
{
// for now (testing ) we only support files under 1000 bytes
byte[] transferData = new byte[Data.Length + 4];
Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
Array.Copy(Data, 0, transferData, 4, Data.Length);
Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
complete = true;
}
else
{
byte[] transferData = new byte[1000 + 4];
Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
Array.Copy(Data, 0, transferData, 4, 1000);
Client.SendXferPacket(XferID, 0, transferData);
Packet++;
DataPointer = 1000;
}
}
public void AckPacket(uint packet)
{
if (!complete)
{
if ((Data.Length - DataPointer) > 1000)
{
byte[] transferData = new byte[1000];
Array.Copy(Data, DataPointer, transferData, 0, 1000);
Client.SendXferPacket(XferID, Packet, transferData);
Packet++;
DataPointer += 1000;
}
else
{
byte[] transferData = new byte[Data.Length - DataPointer];
Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer);
uint endPacket = Packet |= (uint) 0x80000000;
Client.SendXferPacket(XferID, endPacket, transferData);
Packet++;
DataPointer += (Data.Length - DataPointer);
complete = true;
}
}
}
}
}
}

View File

@ -39,12 +39,15 @@ using OpenSim.Region.Communications.Local;
using OpenSim.Region.Environment;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Physics.Manager;
using Nini.Config;
namespace SimpleApp
{
class Program : RegionApplicationBase, conscmd_callback
{
private ModuleLoader m_moduleLoader;
private IConfigSource m_config;
protected override LogBase CreateLog()
{
return new LogBase(null, "SimpleApp", this, false);
@ -86,7 +89,7 @@ namespace SimpleApp
UDPServer udpServer;
m_moduleLoader = new ModuleLoader( m_log );
m_moduleLoader = new ModuleLoader( m_log, m_config );
m_moduleLoader.LoadDefaultSharedModules();
Scene scene = SetupScene(regionInfo, out udpServer);
@ -155,7 +158,7 @@ namespace SimpleApp
protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager)
{
return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, new ModuleLoader( m_log ));
return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, new ModuleLoader( m_log, m_config ));
}
protected override StorageManager CreateStorageManager(RegionInfo regionInfo)

View File

@ -1,148 +1,149 @@
/*
* 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.Collections.Generic;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.ExtensionsScriptModule.CSharp;
using OpenSim.Region.ExtensionsScriptModule.JScript;
using OpenSim.Region.ExtensionsScriptModule.JVMEngine;
namespace OpenSim.Region.ExtensionsScriptModule
{
public class ScriptManager : IRegionModule, IExtensionScriptModule
{
readonly List<IScript> scripts = new List<IScript>();
Scene m_scene;
readonly Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
{
foreach (KeyValuePair<string, IScript> script in compiledscripts)
{
ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
MainLog.Instance.Verbose("Loading " + script.Key);
script.Value.Initialise(scriptInfo);
scripts.Add(script.Value);
}
MainLog.Instance.Verbose(string.Format("Finished loading {0} script(s)", compiledscripts.Count));
}
public ScriptManager()
{
// Default Engines
CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
compilers.Add(csharpCompiler.FileExt(), csharpCompiler);
JScriptEngine jscriptCompiler = new JScriptEngine();
compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler);
JavaEngine javaCompiler = new JavaEngine();
compilers.Add(javaCompiler.FileExt(), javaCompiler);
}
public void Initialise(Scene scene)
{
System.Console.WriteLine("Initialising Extensions Scripting Module");
m_scene = scene;
m_scene.RegisterModuleInterface<IExtensionScriptModule>(this);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "ExtensionsScriptingModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public bool Compile(string filename)
{
foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
{
if (filename.EndsWith(compiler.Key))
{
LoadFromCompiler(compiler.Value.compile(filename));
break;
}
}
return true;
}
public void RunScriptCmd(string[] args)
{
switch (args[0])
{
case "load":
Compile(args[1]);
break;
default:
MainLog.Instance.Error("Unknown script command");
break;
}
}
public bool AddPreCompiledScript(IScript script)
{
MainLog.Instance.Verbose("Loading script " + script.Name);
ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
script.Initialise(scriptInfo);
scripts.Add(script);
return true;
}
}
public interface IExtensionScriptModule
{
bool Compile(string filename);
bool AddPreCompiledScript(IScript script);
}
interface IScriptCompiler
{
Dictionary<string, IScript> compile(string filename);
string FileExt();
}
}
/*
* 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.Collections.Generic;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.ExtensionsScriptModule.CSharp;
using OpenSim.Region.ExtensionsScriptModule.JScript;
using OpenSim.Region.ExtensionsScriptModule.JVMEngine;
using Nini.Config;
namespace OpenSim.Region.ExtensionsScriptModule
{
public class ScriptManager : IRegionModule, IExtensionScriptModule
{
readonly List<IScript> scripts = new List<IScript>();
Scene m_scene;
readonly Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
{
foreach (KeyValuePair<string, IScript> script in compiledscripts)
{
ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
MainLog.Instance.Verbose("Loading " + script.Key);
script.Value.Initialise(scriptInfo);
scripts.Add(script.Value);
}
MainLog.Instance.Verbose(string.Format("Finished loading {0} script(s)", compiledscripts.Count));
}
public ScriptManager()
{
// Default Engines
CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
compilers.Add(csharpCompiler.FileExt(), csharpCompiler);
JScriptEngine jscriptCompiler = new JScriptEngine();
compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler);
JavaEngine javaCompiler = new JavaEngine();
compilers.Add(javaCompiler.FileExt(), javaCompiler);
}
public void Initialise(Scene scene, IConfigSource config)
{
System.Console.WriteLine("Initialising Extensions Scripting Module");
m_scene = scene;
m_scene.RegisterModuleInterface<IExtensionScriptModule>(this);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "ExtensionsScriptingModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
public bool Compile(string filename)
{
foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
{
if (filename.EndsWith(compiler.Key))
{
LoadFromCompiler(compiler.Value.compile(filename));
break;
}
}
return true;
}
public void RunScriptCmd(string[] args)
{
switch (args[0])
{
case "load":
Compile(args[1]);
break;
default:
MainLog.Instance.Error("Unknown script command");
break;
}
}
public bool AddPreCompiledScript(IScript script)
{
MainLog.Instance.Verbose("Loading script " + script.Name);
ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
script.Initialise(scriptInfo);
scripts.Add(script);
return true;
}
}
public interface IExtensionScriptModule
{
bool Compile(string filename);
bool AddPreCompiledScript(IScript script);
}
interface IScriptCompiler
{
Dictionary<string, IScript> compile(string filename);
string FileExt();
}
}

View File

@ -1,132 +1,133 @@
/*
* 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.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Environment.Interfaces;
using libsecondlife;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
/// <summary>
/// This is the root object for ScriptEngine
/// </summary>
[Serializable]
public class ScriptEngine :IRegionModule
{
internal OpenSim.Region.Environment.Scenes.Scene World;
internal 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
internal AppDomainManager m_AppDomainManager;
internal LSLLongCmdHandler m_LSLLongCmdHandler;
private OpenSim.Framework.Console.LogBase m_log;
public ScriptEngine()
{
//Common.SendToDebug("ScriptEngine Object Initialized");
Common.mySE = this;
}
public LogBase Log
{
get { return m_log; }
}
public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger)
{
World = Sceneworld;
m_log = logger;
Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
//m_logger.Status("ScriptEngine", "InitializeEngine");
// Create all objects we'll be using
m_EventQueueManager = new EventQueueManager(this);
m_EventManager = new EventManager(this);
m_ScriptManager = new ScriptManager(this);
m_AppDomainManager = new AppDomainManager();
m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
// Should we iterate the region for scripts that needs starting?
// Or can we assume we are loaded before anything else so we can use proper events?
}
public void Shutdown()
{
// 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
public void Initialise(Scene scene)
{
this.InitializeEngine(scene, MainLog.Instance);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "LSLScriptingModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
}
}
/*
* 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.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Environment.Interfaces;
using libsecondlife;
using Nini.Config;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
/// <summary>
/// This is the root object for ScriptEngine
/// </summary>
[Serializable]
public class ScriptEngine :IRegionModule
{
internal OpenSim.Region.Environment.Scenes.Scene World;
internal 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
internal AppDomainManager m_AppDomainManager;
internal LSLLongCmdHandler m_LSLLongCmdHandler;
private OpenSim.Framework.Console.LogBase m_log;
public ScriptEngine()
{
//Common.SendToDebug("ScriptEngine Object Initialized");
Common.mySE = this;
}
public LogBase Log
{
get { return m_log; }
}
public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger)
{
World = Sceneworld;
m_log = logger;
Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
//m_logger.Status("ScriptEngine", "InitializeEngine");
// Create all objects we'll be using
m_EventQueueManager = new EventQueueManager(this);
m_EventManager = new EventManager(this);
m_ScriptManager = new ScriptManager(this);
m_AppDomainManager = new AppDomainManager();
m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
// Should we iterate the region for scripts that needs starting?
// Or can we assume we are loaded before anything else so we can use proper events?
}
public void Shutdown()
{
// 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
public void Initialise(Scene scene, IConfigSource config)
{
this.InitializeEngine(scene, MainLog.Instance);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "LSLScriptingModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
}
}

View File

@ -475,11 +475,12 @@
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Region.ScriptEngine.DotNetEngine"/>
<!-- For scripting in funny languages by default -->
<Reference name="Microsoft.JScript"/>
<Reference name="XMLRPC.dll"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
@ -592,7 +593,7 @@
<Reference name="OpenSim.Region.Environment"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="Axiom.MathLib.dll"/>
<Reference name="Nini.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
@ -670,7 +671,7 @@
<Reference name="OpenSim.Region.ClientStack"/>
<Reference name="OpenSim.Region.Environment"/>
<Reference name="OpenSim.Region.Terrain.BasicTerrain"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
@ -895,6 +896,7 @@
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.ScriptEngine.Common"/>
<Reference name="Axiom.MathLib.dll" localCopy="false"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
@ -983,6 +985,8 @@
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.ScriptEngine.Common"/>
<Reference name="Axiom.MathLib.dll" localCopy="false"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>