diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting')
5 files changed, 317 insertions, 45 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index e68764a..b9b3ebc 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | |||
@@ -221,6 +221,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
221 | /// | 221 | /// |
222 | /// </summary> | 222 | /// </summary> |
223 | // ----------------------------------------------------------------- | 223 | // ----------------------------------------------------------------- |
224 | public bool TestStore(UUID storeID) | ||
225 | { | ||
226 | if (! m_enabled) return false; | ||
227 | |||
228 | lock (m_JsonValueStore) | ||
229 | return m_JsonValueStore.ContainsKey(storeID); | ||
230 | } | ||
231 | |||
232 | // ----------------------------------------------------------------- | ||
233 | /// <summary> | ||
234 | /// | ||
235 | /// </summary> | ||
236 | // ----------------------------------------------------------------- | ||
224 | public bool TestPath(UUID storeID, string path, bool useJson) | 237 | public bool TestPath(UUID storeID, string path, bool useJson) |
225 | { | 238 | { |
226 | if (! m_enabled) return false; | 239 | if (! m_enabled) return false; |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 0c175ca..29955af 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -92,12 +92,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
92 | } | 92 | } |
93 | catch (Exception e) | 93 | catch (Exception e) |
94 | { | 94 | { |
95 | m_log.ErrorFormat("[JsonStoreScripts] initialization error: {0}",e.Message); | 95 | m_log.ErrorFormat("[JsonStoreScripts]: initialization error: {0}", e.Message); |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | 98 | ||
99 | if (m_enabled) | 99 | if (m_enabled) |
100 | m_log.DebugFormat("[JsonStoreScripts] module is enabled"); | 100 | m_log.DebugFormat("[JsonStoreScripts]: module is enabled"); |
101 | } | 101 | } |
102 | 102 | ||
103 | // ----------------------------------------------------------------- | 103 | // ----------------------------------------------------------------- |
@@ -150,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
150 | m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>(); | 150 | m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>(); |
151 | if (m_comms == null) | 151 | if (m_comms == null) |
152 | { | 152 | { |
153 | m_log.ErrorFormat("[JsonStoreScripts] ScriptModuleComms interface not defined"); | 153 | m_log.ErrorFormat("[JsonStoreScripts]: ScriptModuleComms interface not defined"); |
154 | m_enabled = false; | 154 | m_enabled = false; |
155 | return; | 155 | return; |
156 | } | 156 | } |
@@ -158,40 +158,41 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
158 | m_store = m_scene.RequestModuleInterface<IJsonStoreModule>(); | 158 | m_store = m_scene.RequestModuleInterface<IJsonStoreModule>(); |
159 | if (m_store == null) | 159 | if (m_store == null) |
160 | { | 160 | { |
161 | m_log.ErrorFormat("[JsonStoreScripts] JsonModule interface not defined"); | 161 | m_log.ErrorFormat("[JsonStoreScripts]: JsonModule interface not defined"); |
162 | m_enabled = false; | 162 | m_enabled = false; |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | 165 | ||
166 | try | 166 | try |
167 | { | 167 | { |
168 | m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); | 168 | m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); |
169 | m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); | 169 | m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); |
170 | m_comms.RegisterScriptInvocation(this, "JsonTestStore"); | ||
170 | 171 | ||
171 | m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); | 172 | m_comms.RegisterScriptInvocation(this, "JsonReadNotecard"); |
172 | m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); | 173 | m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard"); |
173 | 174 | ||
174 | m_comms.RegisterScriptInvocation(this,"JsonTestPath"); | 175 | m_comms.RegisterScriptInvocation(this, "JsonTestPath"); |
175 | m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); | 176 | m_comms.RegisterScriptInvocation(this, "JsonTestPathJson"); |
176 | 177 | ||
177 | m_comms.RegisterScriptInvocation(this,"JsonGetValue"); | 178 | m_comms.RegisterScriptInvocation(this, "JsonGetValue"); |
178 | m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); | 179 | m_comms.RegisterScriptInvocation(this, "JsonGetValueJson"); |
179 | 180 | ||
180 | m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); | 181 | m_comms.RegisterScriptInvocation(this, "JsonTakeValue"); |
181 | m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); | 182 | m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson"); |
182 | 183 | ||
183 | m_comms.RegisterScriptInvocation(this,"JsonReadValue"); | 184 | m_comms.RegisterScriptInvocation(this, "JsonReadValue"); |
184 | m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); | 185 | m_comms.RegisterScriptInvocation(this, "JsonReadValueJson"); |
185 | 186 | ||
186 | m_comms.RegisterScriptInvocation(this,"JsonSetValue"); | 187 | m_comms.RegisterScriptInvocation(this, "JsonSetValue"); |
187 | m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); | 188 | m_comms.RegisterScriptInvocation(this, "JsonSetValueJson"); |
188 | 189 | ||
189 | m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); | 190 | m_comms.RegisterScriptInvocation(this, "JsonRemoveValue"); |
190 | } | 191 | } |
191 | catch (Exception e) | 192 | catch (Exception e) |
192 | { | 193 | { |
193 | // See http://opensimulator.org/mantis/view.php?id=5971 for more information | 194 | // See http://opensimulator.org/mantis/view.php?id=5971 for more information |
194 | m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message); | 195 | m_log.WarnFormat("[JsonStoreScripts]: script method registration failed; {0}", e.Message); |
195 | m_enabled = false; | 196 | m_enabled = false; |
196 | } | 197 | } |
197 | } | 198 | } |
@@ -248,6 +249,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
248 | /// | 249 | /// |
249 | /// </summary> | 250 | /// </summary> |
250 | // ----------------------------------------------------------------- | 251 | // ----------------------------------------------------------------- |
252 | protected int JsonTestStore(UUID hostID, UUID scriptID, UUID storeID) | ||
253 | { | ||
254 | return m_store.TestStore(storeID) ? 1 : 0; | ||
255 | } | ||
256 | |||
257 | // ----------------------------------------------------------------- | ||
258 | /// <summary> | ||
259 | /// | ||
260 | /// </summary> | ||
261 | // ----------------------------------------------------------------- | ||
251 | protected UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) | 262 | protected UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) |
252 | { | 263 | { |
253 | UUID reqID = UUID.Random(); | 264 | UUID reqID = UUID.Random(); |
@@ -354,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
354 | } | 365 | } |
355 | catch (Exception e) | 366 | catch (Exception e) |
356 | { | 367 | { |
357 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | 368 | m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); |
358 | } | 369 | } |
359 | 370 | ||
360 | DispatchValue(scriptID,reqID,String.Empty); | 371 | DispatchValue(scriptID,reqID,String.Empty); |
@@ -389,7 +400,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
389 | } | 400 | } |
390 | catch (Exception e) | 401 | catch (Exception e) |
391 | { | 402 | { |
392 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | 403 | m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); |
393 | } | 404 | } |
394 | 405 | ||
395 | DispatchValue(scriptID,reqID,String.Empty); | 406 | DispatchValue(scriptID,reqID,String.Empty); |
@@ -421,7 +432,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
421 | if (a.Type != (sbyte)AssetType.Notecard) | 432 | if (a.Type != (sbyte)AssetType.Notecard) |
422 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); | 433 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); |
423 | 434 | ||
424 | m_log.DebugFormat("[JsonStoreScripts] read notecard in context {0}",storeID); | 435 | m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); |
425 | 436 | ||
426 | try | 437 | try |
427 | { | 438 | { |
@@ -432,7 +443,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
432 | } | 443 | } |
433 | catch (Exception e) | 444 | catch (Exception e) |
434 | { | 445 | { |
435 | m_log.WarnFormat("[JsonStoreScripts] Json parsing failed; {0}",e.Message); | 446 | m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message); |
436 | } | 447 | } |
437 | 448 | ||
438 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); | 449 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); |
@@ -495,4 +506,4 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
495 | m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); | 506 | m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); |
496 | } | 507 | } |
497 | } | 508 | } |
498 | } | 509 | } \ No newline at end of file |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs new file mode 100644 index 0000000..8042a93 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.Scripting.ScriptModuleComms; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.ScriptEngine.Shared; | ||
40 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Tests.Common; | ||
43 | using OpenSim.Tests.Common.Mock; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Tests for inventory functions in LSL | ||
49 | /// </summary> | ||
50 | [TestFixture] | ||
51 | public class JsonStoreScriptModuleTests : OpenSimTestCase | ||
52 | { | ||
53 | private Scene m_scene; | ||
54 | private MockScriptEngine m_engine; | ||
55 | private ScriptModuleCommsModule m_smcm; | ||
56 | |||
57 | [SetUp] | ||
58 | public override void SetUp() | ||
59 | { | ||
60 | base.SetUp(); | ||
61 | |||
62 | IConfigSource configSource = new IniConfigSource(); | ||
63 | IConfig jsonStoreConfig = configSource.AddConfig("JsonStore"); | ||
64 | jsonStoreConfig.Set("Enabled", "true"); | ||
65 | |||
66 | m_engine = new MockScriptEngine(); | ||
67 | m_smcm = new ScriptModuleCommsModule(); | ||
68 | JsonStoreModule jsm = new JsonStoreModule(); | ||
69 | JsonStoreScriptModule jssm = new JsonStoreScriptModule(); | ||
70 | |||
71 | m_scene = new SceneHelpers().SetupScene(); | ||
72 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); | ||
73 | |||
74 | try | ||
75 | { | ||
76 | m_smcm.RegisterScriptInvocation(this, "DummyTestMethod"); | ||
77 | } | ||
78 | catch (ArgumentException) | ||
79 | { | ||
80 | Assert.Ignore("Ignoring test since running on .NET 3.5 or earlier."); | ||
81 | } | ||
82 | |||
83 | // XXX: Unfortunately, ICommsModule currently has no way of deregistering methods. | ||
84 | } | ||
85 | |||
86 | private object InvokeOp(string name, params object[] args) | ||
87 | { | ||
88 | return m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, name, args); | ||
89 | } | ||
90 | |||
91 | [Test] | ||
92 | public void TestJsonCreateStore() | ||
93 | { | ||
94 | TestHelpers.InMethod(); | ||
95 | // TestHelpers.EnableLogging(); | ||
96 | |||
97 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); | ||
98 | Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); | ||
99 | } | ||
100 | |||
101 | [Test] | ||
102 | public void TestJsonDestroyStore() | ||
103 | { | ||
104 | TestHelpers.InMethod(); | ||
105 | // TestHelpers.EnableLogging(); | ||
106 | |||
107 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); | ||
108 | int dsrv = (int)InvokeOp("JsonDestroyStore", storeId); | ||
109 | |||
110 | Assert.That(dsrv, Is.EqualTo(1)); | ||
111 | |||
112 | int tprv = (int)InvokeOp("JsonTestPath", storeId, "Hello"); | ||
113 | Assert.That(tprv, Is.EqualTo(0)); | ||
114 | } | ||
115 | |||
116 | [Test] | ||
117 | public void TestJsonGetValue() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | // TestHelpers.EnableLogging(); | ||
121 | |||
122 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); | ||
123 | |||
124 | string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); | ||
125 | Assert.That(value, Is.EqualTo("World")); | ||
126 | } | ||
127 | |||
128 | // [Test] | ||
129 | // public void TestJsonTakeValue() | ||
130 | // { | ||
131 | // TestHelpers.InMethod(); | ||
132 | //// TestHelpers.EnableLogging(); | ||
133 | // | ||
134 | // UUID storeId | ||
135 | // = (UUID)m_smcm.InvokeOperation( | ||
136 | // UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); | ||
137 | // | ||
138 | // string value | ||
139 | // = (string)m_smcm.InvokeOperation( | ||
140 | // UUID.Zero, UUID.Zero, "JsonTakeValue", new object[] { storeId, "Hello" }); | ||
141 | // | ||
142 | // Assert.That(value, Is.EqualTo("World")); | ||
143 | // | ||
144 | // string value2 | ||
145 | // = (string)m_smcm.InvokeOperation( | ||
146 | // UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" }); | ||
147 | // | ||
148 | // Assert.That(value, Is.Null); | ||
149 | // } | ||
150 | |||
151 | [Test] | ||
152 | public void TestJsonRemoveValue() | ||
153 | { | ||
154 | TestHelpers.InMethod(); | ||
155 | // TestHelpers.EnableLogging(); | ||
156 | |||
157 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); | ||
158 | |||
159 | int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); | ||
160 | Assert.That(returnValue, Is.EqualTo(1)); | ||
161 | |||
162 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); | ||
163 | Assert.That(result, Is.EqualTo(0)); | ||
164 | |||
165 | string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); | ||
166 | Assert.That(returnValue2, Is.EqualTo("")); | ||
167 | } | ||
168 | |||
169 | [Test] | ||
170 | public void TestJsonTestPath() | ||
171 | { | ||
172 | TestHelpers.InMethod(); | ||
173 | // TestHelpers.EnableLogging(); | ||
174 | |||
175 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); | ||
176 | |||
177 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); | ||
178 | Assert.That(result, Is.EqualTo(1)); | ||
179 | } | ||
180 | |||
181 | [Test] | ||
182 | public void TestJsonSetValue() | ||
183 | { | ||
184 | TestHelpers.InMethod(); | ||
185 | // TestHelpers.EnableLogging(); | ||
186 | |||
187 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); | ||
188 | |||
189 | int result = (int)InvokeOp("JsonSetValue", storeId, "Hello", "World"); | ||
190 | Assert.That(result, Is.EqualTo(1)); | ||
191 | |||
192 | string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); | ||
193 | Assert.That(value, Is.EqualTo("World")); | ||
194 | } | ||
195 | |||
196 | public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; } | ||
197 | } | ||
198 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs index 6120a81..709d389 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
46 | { | 46 | { |
47 | public class XmlRpcInfo | 47 | public class XmlRpcInfo |
48 | { | 48 | { |
49 | public UUID item; | ||
49 | public UUID channel; | 50 | public UUID channel; |
50 | public string uri; | 51 | public string uri; |
51 | } | 52 | } |
@@ -88,6 +89,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
88 | return; | 89 | return; |
89 | 90 | ||
90 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | 91 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); |
92 | |||
93 | IScriptModule scriptEngine = scene.RequestModuleInterface<IScriptModule>(); | ||
94 | if ( scriptEngine != null ) | ||
95 | { | ||
96 | scriptEngine.OnScriptRemoved += this.ScriptRemoved; | ||
97 | scriptEngine.OnObjectRemoved += this.ObjectRemoved; | ||
98 | |||
99 | } | ||
91 | } | 100 | } |
92 | 101 | ||
93 | public void RegionLoaded(Scene scene) | 102 | public void RegionLoaded(Scene scene) |
@@ -120,22 +129,36 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
120 | 129 | ||
121 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | 130 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) |
122 | { | 131 | { |
123 | if (!m_Channels.ContainsKey(itemID)) | 132 | if (!m_Enabled) |
124 | { | 133 | return; |
125 | XmlRpcInfo info = new XmlRpcInfo(); | ||
126 | info.channel = channel; | ||
127 | info.uri = uri; | ||
128 | 134 | ||
129 | bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>( | 135 | m_log.InfoFormat("[XMLRPC GRID ROUTER]: New receiver Obj: {0} Ch: {1} ID: {2} URI: {3}", |
130 | "POST", m_ServerURI+"/RegisterChannel/", info); | 136 | objectID.ToString(), channel.ToString(), itemID.ToString(), uri); |
131 | 137 | ||
132 | if (!success) | 138 | XmlRpcInfo info = new XmlRpcInfo(); |
133 | { | 139 | info.channel = channel; |
134 | m_log.Error("[XMLRPC GRID ROUTER] Error contacting server"); | 140 | info.uri = uri; |
135 | } | 141 | info.item = itemID; |
142 | |||
143 | bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>( | ||
144 | "POST", m_ServerURI+"/RegisterChannel/", info); | ||
136 | 145 | ||
137 | m_Channels[itemID] = channel; | 146 | if (!success) |
147 | { | ||
148 | m_log.Error("[XMLRPC GRID ROUTER] Error contacting server"); | ||
138 | } | 149 | } |
150 | |||
151 | m_Channels[itemID] = channel; | ||
152 | |||
153 | } | ||
154 | |||
155 | public void UnRegisterReceiver(string channelID, UUID itemID) | ||
156 | { | ||
157 | if (!m_Enabled) | ||
158 | return; | ||
159 | |||
160 | RemoveChannel(itemID); | ||
161 | |||
139 | } | 162 | } |
140 | 163 | ||
141 | public void ScriptRemoved(UUID itemID) | 164 | public void ScriptRemoved(UUID itemID) |
@@ -143,10 +166,33 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
143 | if (!m_Enabled) | 166 | if (!m_Enabled) |
144 | return; | 167 | return; |
145 | 168 | ||
146 | if (m_Channels.ContainsKey(itemID)) | 169 | RemoveChannel(itemID); |
170 | |||
171 | } | ||
172 | |||
173 | public void ObjectRemoved(UUID objectID) | ||
174 | { | ||
175 | // m_log.InfoFormat("[XMLRPC GRID ROUTER]: Object Removed {0}",objectID.ToString()); | ||
176 | } | ||
177 | |||
178 | private bool RemoveChannel(UUID itemID) | ||
179 | { | ||
180 | if(!m_Channels.ContainsKey(itemID)) | ||
181 | { | ||
182 | m_log.InfoFormat("[XMLRPC GRID ROUTER]: Attempted to unregister non-existing Item: {0}", itemID.ToString()); | ||
183 | return false; | ||
184 | } | ||
185 | |||
186 | XmlRpcInfo info = new XmlRpcInfo(); | ||
187 | |||
188 | info.channel = m_Channels[itemID]; | ||
189 | info.item = itemID; | ||
190 | info.uri = "http://0.0.0.0:00"; | ||
191 | |||
192 | if (info != null) | ||
147 | { | 193 | { |
148 | bool success = SynchronousRestObjectRequester.MakeRequest<UUID, bool>( | 194 | bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>( |
149 | "POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]); | 195 | "POST", m_ServerURI+"/RemoveChannel/", info); |
150 | 196 | ||
151 | if (!success) | 197 | if (!success) |
152 | { | 198 | { |
@@ -154,11 +200,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
154 | } | 200 | } |
155 | 201 | ||
156 | m_Channels.Remove(itemID); | 202 | m_Channels.Remove(itemID); |
203 | return true; | ||
157 | } | 204 | } |
158 | } | 205 | return false; |
159 | |||
160 | public void ObjectRemoved(UUID objectID) | ||
161 | { | ||
162 | } | 206 | } |
163 | } | 207 | } |
164 | } | 208 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs index 4bde52a..32549d6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs | |||
@@ -104,12 +104,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | public void UnRegisterReceiver(string channelID, UUID itemID) | ||
108 | { | ||
109 | } | ||
110 | |||
107 | public void ScriptRemoved(UUID itemID) | 111 | public void ScriptRemoved(UUID itemID) |
108 | { | 112 | { |
113 | // System.Console.WriteLine("TEST Script Removed!"); | ||
109 | } | 114 | } |
110 | 115 | ||
111 | public void ObjectRemoved(UUID objectID) | 116 | public void ObjectRemoved(UUID objectID) |
112 | { | 117 | { |
118 | // System.Console.WriteLine("TEST Obj Removed!"); | ||
113 | } | 119 | } |
114 | } | 120 | } |
115 | } | 121 | } |