diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting')
3 files changed, 117 insertions, 59 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 03481d2..6fb28e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -43,13 +43,17 @@ using OpenMetaverse; | |||
43 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
44 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
46 | using Mono.Addins; | ||
46 | 47 | ||
47 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 48 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
48 | { | 49 | { |
49 | public class MRMModule : IRegionModule, IMRMModule | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MRMModule")] |
51 | public class MRMModule : INonSharedRegionModule, IMRMModule | ||
50 | { | 52 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | private Scene m_scene; | 54 | private Scene m_scene; |
55 | private bool m_Enabled; | ||
56 | private bool m_Hidden; | ||
53 | 57 | ||
54 | private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); | 58 | private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); |
55 | 59 | ||
@@ -67,7 +71,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
67 | m_extensions[typeof (T)] = instance; | 71 | m_extensions[typeof (T)] = instance; |
68 | } | 72 | } |
69 | 73 | ||
70 | public void Initialise(Scene scene, IConfigSource source) | 74 | #region INonSharedRegionModule |
75 | |||
76 | public void Initialise(IConfigSource source) | ||
71 | { | 77 | { |
72 | if (source.Configs["MRM"] != null) | 78 | if (source.Configs["MRM"] != null) |
73 | { | 79 | { |
@@ -76,23 +82,60 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
76 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) | 82 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) |
77 | { | 83 | { |
78 | m_log.Info("[MRM]: Enabling MRM Module"); | 84 | m_log.Info("[MRM]: Enabling MRM Module"); |
79 | m_scene = scene; | 85 | m_Enabled = true; |
86 | m_Hidden = source.Configs["MRM"].GetBoolean("Hidden", false); | ||
87 | } | ||
88 | } | ||
89 | } | ||
80 | 90 | ||
81 | // when hidden, we don't listen for client initiated script events | 91 | public void AddRegion(Scene scene) |
82 | // only making the MRM engine available for region modules | 92 | { |
83 | if (!source.Configs["MRM"].GetBoolean("Hidden", false)) | 93 | if (!m_Enabled) |
84 | { | 94 | return; |
85 | scene.EventManager.OnRezScript += EventManager_OnRezScript; | ||
86 | scene.EventManager.OnStopScript += EventManager_OnStopScript; | ||
87 | } | ||
88 | 95 | ||
89 | scene.EventManager.OnFrame += EventManager_OnFrame; | 96 | m_scene = scene; |
90 | 97 | ||
91 | scene.RegisterModuleInterface<IMRMModule>(this); | 98 | // when hidden, we don't listen for client initiated script events |
92 | } | 99 | // only making the MRM engine available for region modules |
100 | if (!m_Hidden) | ||
101 | { | ||
102 | scene.EventManager.OnRezScript += EventManager_OnRezScript; | ||
103 | scene.EventManager.OnStopScript += EventManager_OnStopScript; | ||
93 | } | 104 | } |
105 | |||
106 | scene.EventManager.OnFrame += EventManager_OnFrame; | ||
107 | |||
108 | scene.RegisterModuleInterface<IMRMModule>(this); | ||
109 | } | ||
110 | |||
111 | public void RegionLoaded(Scene scene) | ||
112 | { | ||
94 | } | 113 | } |
95 | 114 | ||
115 | public void RemoveRegion(Scene scene) | ||
116 | { | ||
117 | } | ||
118 | |||
119 | public void Close() | ||
120 | { | ||
121 | foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) | ||
122 | { | ||
123 | pair.Value.Stop(); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public string Name | ||
128 | { | ||
129 | get { return "MiniRegionModule"; } | ||
130 | } | ||
131 | |||
132 | public Type ReplaceableInterface | ||
133 | { | ||
134 | get { return null; } | ||
135 | } | ||
136 | |||
137 | #endregion | ||
138 | |||
96 | void EventManager_OnStopScript(uint localID, UUID itemID) | 139 | void EventManager_OnStopScript(uint localID, UUID itemID) |
97 | { | 140 | { |
98 | if (m_scripts.ContainsKey(itemID)) | 141 | if (m_scripts.ContainsKey(itemID)) |
@@ -293,28 +336,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
293 | mmb.InitMiniModule(world, host, itemID); | 336 | mmb.InitMiniModule(world, host, itemID); |
294 | } | 337 | } |
295 | 338 | ||
296 | public void PostInitialise() | ||
297 | { | ||
298 | } | ||
299 | |||
300 | public void Close() | ||
301 | { | ||
302 | foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) | ||
303 | { | ||
304 | pair.Value.Stop(); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | public string Name | ||
309 | { | ||
310 | get { return "MiniRegionModule"; } | ||
311 | } | ||
312 | |||
313 | public bool IsSharedModule | ||
314 | { | ||
315 | get { return false; } | ||
316 | } | ||
317 | |||
318 | /// <summary> | 339 | /// <summary> |
319 | /// Stolen from ScriptEngine Common | 340 | /// Stolen from ScriptEngine Common |
320 | /// </summary> | 341 | /// </summary> |
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs index 2187449..6120a81 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using log4net; | 32 | using log4net; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using Mono.Addins; | ||
35 | 36 | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
@@ -49,7 +50,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
49 | public string uri; | 50 | public string uri; |
50 | } | 51 | } |
51 | 52 | ||
52 | public class XmlRpcGridRouter : IRegionModule, IXmlRpcRouter | 53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGridRouter")] |
54 | public class XmlRpcGridRouter : INonSharedRegionModule, IXmlRpcRouter | ||
53 | { | 55 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 57 | ||
@@ -59,9 +61,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
59 | private bool m_Enabled = false; | 61 | private bool m_Enabled = false; |
60 | private string m_ServerURI = String.Empty; | 62 | private string m_ServerURI = String.Empty; |
61 | 63 | ||
62 | public void Initialise(Scene scene, IConfigSource config) | 64 | #region INonSharedRegionModule |
65 | |||
66 | public void Initialise(IConfigSource config) | ||
63 | { | 67 | { |
64 | IConfig startupConfig = config.Configs["Startup"]; | 68 | IConfig startupConfig = config.Configs["XMLRPC"]; |
65 | if (startupConfig == null) | 69 | if (startupConfig == null) |
66 | return; | 70 | return; |
67 | 71 | ||
@@ -74,16 +78,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
74 | m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); | 78 | m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); |
75 | return; | 79 | return; |
76 | } | 80 | } |
77 | |||
78 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
79 | m_Enabled = true; | 81 | m_Enabled = true; |
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | public void PostInitialise() | 85 | public void AddRegion(Scene scene) |
86 | { | ||
87 | if (!m_Enabled) | ||
88 | return; | ||
89 | |||
90 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
91 | } | ||
92 | |||
93 | public void RegionLoaded(Scene scene) | ||
84 | { | 94 | { |
85 | } | 95 | } |
86 | 96 | ||
97 | public void RemoveRegion(Scene scene) | ||
98 | { | ||
99 | if (!m_Enabled) | ||
100 | return; | ||
101 | |||
102 | scene.UnregisterModuleInterface<IXmlRpcRouter>(this); | ||
103 | } | ||
104 | |||
87 | public void Close() | 105 | public void Close() |
88 | { | 106 | { |
89 | } | 107 | } |
@@ -93,11 +111,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
93 | get { return "XmlRpcGridRouterModule"; } | 111 | get { return "XmlRpcGridRouterModule"; } |
94 | } | 112 | } |
95 | 113 | ||
96 | public bool IsSharedModule | 114 | public Type ReplaceableInterface |
97 | { | 115 | { |
98 | get { return false; } | 116 | get { return null; } |
99 | } | 117 | } |
100 | 118 | ||
119 | #endregion | ||
120 | |||
101 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | 121 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) |
102 | { | 122 | { |
103 | if (!m_Channels.ContainsKey(itemID)) | 123 | if (!m_Channels.ContainsKey(itemID)) |
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs index 11c87f8..4bde52a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using Mono.Addins; | ||
34 | 35 | ||
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
@@ -39,32 +40,46 @@ using OpenSim.Region.Framework.Scenes; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule | 41 | namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule |
41 | { | 42 | { |
42 | public class XmlRpcRouter : IRegionModule, IXmlRpcRouter | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcRouter")] |
44 | public class XmlRpcRouter : INonSharedRegionModule, IXmlRpcRouter | ||
43 | { | 45 | { |
44 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | private bool m_enabled = false; | 47 | |
46 | public void Initialise(Scene scene, IConfigSource config) | 48 | private bool m_Enabled; |
49 | |||
50 | #region INonSharedRegionModule | ||
51 | |||
52 | public void Initialise(IConfigSource config) | ||
47 | { | 53 | { |
48 | IConfig startupConfig = config.Configs["XMLRPC"]; | 54 | IConfig startupConfig = config.Configs["XMLRPC"]; |
49 | if (startupConfig == null) | 55 | if (startupConfig == null) |
50 | return; | 56 | return; |
51 | 57 | ||
52 | if (startupConfig.GetString("XmlRpcRouterModule", | 58 | if (startupConfig.GetString("XmlRpcRouterModule", |
53 | "") == "XmlRpcRouterModule") | 59 | "XmlRpcRouterModule") == "XmlRpcRouterModule") |
54 | { | 60 | m_Enabled = true; |
55 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | 61 | } |
56 | m_enabled = true; | 62 | |
57 | } | 63 | public void AddRegion(Scene scene) |
58 | else | 64 | { |
59 | { | 65 | if (!m_Enabled) |
60 | m_enabled = false; | 66 | return; |
61 | } | 67 | |
68 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
62 | } | 69 | } |
63 | 70 | ||
64 | public void PostInitialise() | 71 | public void RegionLoaded(Scene scene) |
65 | { | 72 | { |
66 | } | 73 | } |
67 | 74 | ||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | if (!m_Enabled) | ||
78 | return; | ||
79 | |||
80 | scene.UnregisterModuleInterface<IXmlRpcRouter>(this); | ||
81 | } | ||
82 | |||
68 | public void Close() | 83 | public void Close() |
69 | { | 84 | { |
70 | } | 85 | } |
@@ -74,14 +89,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule | |||
74 | get { return "XmlRpcRouterModule"; } | 89 | get { return "XmlRpcRouterModule"; } |
75 | } | 90 | } |
76 | 91 | ||
77 | public bool IsSharedModule | 92 | public Type ReplaceableInterface |
78 | { | 93 | { |
79 | get { return false; } | 94 | get { return null; } |
80 | } | 95 | } |
81 | 96 | ||
97 | #endregion | ||
98 | |||
82 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | 99 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) |
83 | { | 100 | { |
84 | if (m_enabled) | 101 | if (m_Enabled) |
85 | { | 102 | { |
86 | scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri }); | 103 | scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri }); |
87 | } | 104 | } |