aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-02-07 23:09:47 +0000
committerJustin Clark-Casey (justincc)2013-02-07 23:09:47 +0000
commit9e17dc3daa04644c1a565d819a614c02022bdeed (patch)
tree014eb8cec88c68b2dedde009a508dde3b5b52aca /OpenSim/Region/OptionalModules
parentFix a recent regression in e17392a where JsonSetValue() stopped working (prob... (diff)
parentPlumb the path from the client to the extra physics params and back (diff)
downloadopensim-SC_OLD-9e17dc3daa04644c1a565d819a614c02022bdeed.zip
opensim-SC_OLD-9e17dc3daa04644c1a565d819a614c02022bdeed.tar.gz
opensim-SC_OLD-9e17dc3daa04644c1a565d819a614c02022bdeed.tar.bz2
opensim-SC_OLD-9e17dc3daa04644c1a565d819a614c02022bdeed.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs174
-rwxr-xr-xOpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs19
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs61
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs5
5 files changed, 249 insertions, 15 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 781539a..0ac56fa 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1678,5 +1678,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1678 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) 1678 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1679 { 1679 {
1680 } 1680 }
1681
1682 public void SendPartPhysicsProprieties(ISceneEntity entity)
1683 {
1684 }
1685
1681 } 1686 }
1682} 1687}
diff --git a/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs b/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs
new file mode 100644
index 0000000..112ba4e
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs
@@ -0,0 +1,174 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using OpenSim.Framework.Servers;
32using Mono.Addins;
33using log4net;
34using Nini.Config;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37
38using OpenSim.Framework.Servers.HttpServer;
39
40
41namespace OpenSim.Region.OptionalModules.WebSocketEchoModule
42{
43
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebSocketEchoModule")]
45 public class WebSocketEchoModule : ISharedRegionModule
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private bool enabled;
49 public string Name { get { return "WebSocketEchoModule"; } }
50
51 public Type ReplaceableInterface { get { return null; } }
52
53
54 private HashSet<WebSocketHttpServerHandler> _activeHandlers = new HashSet<WebSocketHttpServerHandler>();
55
56 public void Initialise(IConfigSource pConfig)
57 {
58 enabled =(pConfig.Configs["WebSocketEcho"] != null);
59 if (enabled)
60 m_log.DebugFormat("[WebSocketEchoModule]: INITIALIZED MODULE");
61 }
62
63 /// <summary>
64 /// This method sets up the callback to WebSocketHandlerCallback below when a HTTPRequest comes in for /echo
65 /// </summary>
66 public void PostInitialise()
67 {
68 if (enabled)
69 MainServer.Instance.AddWebSocketHandler("/echo", WebSocketHandlerCallback);
70 }
71
72 // This gets called by BaseHttpServer and gives us an opportunity to set things on the WebSocket handler before we turn it on
73 public void WebSocketHandlerCallback(string path, WebSocketHttpServerHandler handler)
74 {
75 SubscribeToEvents(handler);
76 handler.SetChunksize(8192);
77 handler.NoDelay_TCP_Nagle = true;
78 handler.HandshakeAndUpgrade();
79 }
80
81 //These are our normal events
82 public void SubscribeToEvents(WebSocketHttpServerHandler handler)
83 {
84 handler.OnClose += HandlerOnOnClose;
85 handler.OnText += HandlerOnOnText;
86 handler.OnUpgradeCompleted += HandlerOnOnUpgradeCompleted;
87 handler.OnData += HandlerOnOnData;
88 handler.OnPong += HandlerOnOnPong;
89 }
90
91 public void UnSubscribeToEvents(WebSocketHttpServerHandler handler)
92 {
93 handler.OnClose -= HandlerOnOnClose;
94 handler.OnText -= HandlerOnOnText;
95 handler.OnUpgradeCompleted -= HandlerOnOnUpgradeCompleted;
96 handler.OnData -= HandlerOnOnData;
97 handler.OnPong -= HandlerOnOnPong;
98 }
99
100 private void HandlerOnOnPong(object sender, PongEventArgs pongdata)
101 {
102 m_log.Info("[WebSocketEchoModule]: Got a pong.. ping time: " + pongdata.PingResponseMS);
103 }
104
105 private void HandlerOnOnData(object sender, WebsocketDataEventArgs data)
106 {
107 WebSocketHttpServerHandler obj = sender as WebSocketHttpServerHandler;
108 obj.SendData(data.Data);
109 m_log.Info("[WebSocketEchoModule]: We received a bunch of ugly non-printable bytes");
110 obj.SendPingCheck();
111 }
112
113
114 private void HandlerOnOnUpgradeCompleted(object sender, UpgradeCompletedEventArgs completeddata)
115 {
116 WebSocketHttpServerHandler obj = sender as WebSocketHttpServerHandler;
117 _activeHandlers.Add(obj);
118 }
119
120 private void HandlerOnOnText(object sender, WebsocketTextEventArgs text)
121 {
122 WebSocketHttpServerHandler obj = sender as WebSocketHttpServerHandler;
123 obj.SendMessage(text.Data);
124 m_log.Info("[WebSocketEchoModule]: We received this: " + text.Data);
125 }
126
127 // Remove the references to our handler
128 private void HandlerOnOnClose(object sender, CloseEventArgs closedata)
129 {
130 WebSocketHttpServerHandler obj = sender as WebSocketHttpServerHandler;
131 UnSubscribeToEvents(obj);
132
133 lock (_activeHandlers)
134 _activeHandlers.Remove(obj);
135 obj.Dispose();
136 }
137
138 // Shutting down.. so shut down all sockets.
139 // Note.. this should be done outside of an ienumerable if you're also hook to the close event.
140 public void Close()
141 {
142 if (!enabled)
143 return;
144
145 // We convert this to a for loop so we're not in in an IEnumerable when the close
146 //call triggers an event which then removes item from _activeHandlers that we're enumerating
147 WebSocketHttpServerHandler[] items = new WebSocketHttpServerHandler[_activeHandlers.Count];
148 _activeHandlers.CopyTo(items);
149
150 for (int i = 0; i < items.Length; i++)
151 {
152 items[i].Close(string.Empty);
153 items[i].Dispose();
154 }
155 _activeHandlers.Clear();
156 MainServer.Instance.RemoveWebSocketHandler("/echo");
157 }
158
159 public void AddRegion(Scene scene)
160 {
161 m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName);
162 }
163
164 public void RemoveRegion(Scene scene)
165 {
166 m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
167 }
168
169 public void RegionLoaded(Scene scene)
170 {
171 m_log.DebugFormat("[WebSocketEchoModule]: REGION {0} LOADED", scene.RegionInfo.RegionName);
172 }
173 }
174} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
index 40f7fbc..3083a33 100755
--- a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
+++ b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
@@ -146,7 +146,7 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
146 { 146 {
147 foreach (PhysParameterEntry ppe in physScene.GetParameterList()) 147 foreach (PhysParameterEntry ppe in physScene.GetParameterList())
148 { 148 {
149 float val = 0.0f; 149 string val = string.Empty;
150 if (physScene.GetPhysicsParameter(ppe.name, out val)) 150 if (physScene.GetPhysicsParameter(ppe.name, out val))
151 { 151 {
152 WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, ppe.name, val); 152 WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, ppe.name, val);
@@ -159,7 +159,7 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
159 } 159 }
160 else 160 else
161 { 161 {
162 float val = 0.0f; 162 string val = string.Empty;
163 if (physScene.GetPhysicsParameter(parm, out val)) 163 if (physScene.GetPhysicsParameter(parm, out val))
164 { 164 {
165 WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, parm, val); 165 WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, parm, val);
@@ -185,21 +185,12 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
185 return; 185 return;
186 } 186 }
187 string parm = "xxx"; 187 string parm = "xxx";
188 float val = 0f; 188 string valparm = String.Empty;
189 uint localID = (uint)PhysParameterEntry.APPLY_TO_NONE; // set default value 189 uint localID = (uint)PhysParameterEntry.APPLY_TO_NONE; // set default value
190 try 190 try
191 { 191 {
192 parm = cmdparms[2]; 192 parm = cmdparms[2];
193 string valparm = cmdparms[3].ToLower(); 193 valparm = cmdparms[3].ToLower();
194 if (valparm == "true")
195 val = PhysParameterEntry.NUMERIC_TRUE;
196 else
197 {
198 if (valparm == "false")
199 val = PhysParameterEntry.NUMERIC_FALSE;
200 else
201 val = float.Parse(valparm, Culture.NumberFormatInfo);
202 }
203 if (cmdparms.Length > 4) 194 if (cmdparms.Length > 4)
204 { 195 {
205 if (cmdparms[4].ToLower() == "all") 196 if (cmdparms[4].ToLower() == "all")
@@ -224,7 +215,7 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
224 IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters; 215 IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
225 if (physScene != null) 216 if (physScene != null)
226 { 217 {
227 if (!physScene.SetPhysicsParameter(parm, val, localID)) 218 if (!physScene.SetPhysicsParameter(parm, valparm, localID))
228 { 219 {
229 WriteError("Failed set of parameter '{0}' for region '{1}'", parm, scene.RegionInfo.RegionName); 220 WriteError("Failed set of parameter '{0}' for region '{1}'", parm, scene.RegionInfo.RegionName);
230 } 221 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
index eddae38..aea94ea 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
@@ -54,6 +54,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
54 private MockScriptEngine m_engine; 54 private MockScriptEngine m_engine;
55 private ScriptModuleCommsModule m_smcm; 55 private ScriptModuleCommsModule m_smcm;
56 56
57 [TestFixtureSetUp]
58 public void FixtureInit()
59 {
60 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
61 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
62 }
63
64 [TestFixtureTearDown]
65 public void TearDown()
66 {
67 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
68 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
69 // tests really shouldn't).
70 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
71 }
72
57 [SetUp] 73 [SetUp]
58 public override void SetUp() 74 public override void SetUp()
59 { 75 {
@@ -85,7 +101,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
85 101
86 private object InvokeOp(string name, params object[] args) 102 private object InvokeOp(string name, params object[] args)
87 { 103 {
88 return m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, name, args); 104 return InvokeOpOnHost(name, UUID.Zero, args);
105 }
106
107 private object InvokeOpOnHost(string name, UUID hostId, params object[] args)
108 {
109 return m_smcm.InvokeOperation(hostId, UUID.Zero, name, args);
89 } 110 }
90 111
91 [Test] 112 [Test]
@@ -193,6 +214,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
193 Assert.That(value, Is.EqualTo("Times")); 214 Assert.That(value, Is.EqualTo("Times"));
194 } 215 }
195 216
217 /// <summary>
218 /// Test for reading and writing json to a notecard
219 /// </summary>
220 /// <remarks>
221 /// TODO: Really needs to test correct receipt of the link_message event. Could do this by directly fetching
222 /// it via the MockScriptEngine or perhaps by a dummy script instance.
223 /// </remarks>
224 [Test]
225 public void TestJsonWriteReadNotecard()
226 {
227 TestHelpers.InMethod();
228 TestHelpers.EnableLogging();
229
230 string notecardName = "nc1";
231
232 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1));
233 m_scene.AddSceneObject(so);
234
235 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }");
236
237 // Write notecard
238 UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName);
239 Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
240
241 TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName);
242 Assert.That(nc1Item, Is.Not.Null);
243
244 // TODO: Should probably independently check the contents.
245
246 // Read notecard
247 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }");
248 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName);
249 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
250
251 string value = (string)InvokeOp("JsonGetValue", storeId, "Hello");
252 Assert.That(value, Is.EqualTo("World"));
253 }
254
196 public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; } 255 public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; }
197 } 256 }
198} \ No newline at end of file 257} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 5ea2bcd..6bd27f0 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -1234,5 +1234,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1234 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) 1234 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1235 { 1235 {
1236 } 1236 }
1237
1238 public void SendPartPhysicsProprieties(ISceneEntity entity)
1239 {
1240 }
1241
1237 } 1242 }
1238} 1243}