aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2013-02-07 20:51:51 +0000
committerMelanie2013-02-07 20:51:51 +0000
commit45f5a6a6db16538d864ff90ab6952aea13007514 (patch)
tree48583f7c77afd88a4760ea9db9159741f659fe5b /OpenSim/Region
parentRename Bounciness to Restitution (diff)
parentChange passed PhysicsParameter value from float to the more general string value (diff)
downloadopensim-SC_OLD-45f5a6a6db16538d864ff90ab6952aea13007514.zip
opensim-SC_OLD-45f5a6a6db16538d864ff90ab6952aea13007514.tar.gz
opensim-SC_OLD-45f5a6a6db16538d864ff90ab6952aea13007514.tar.bz2
opensim-SC_OLD-45f5a6a6db16538d864ff90ab6952aea13007514.tar.xz
Merge branch 'master' into careminster
Conflicts: bin/HttpServer_OpenSim.dll
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs174
-rwxr-xr-xOpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs19
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs34
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs41
-rwxr-xr-xOpenSim/Region/Physics/Manager/IPhysicsParameters.cs6
5 files changed, 231 insertions, 43 deletions
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/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 965c382..601c78c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -641,24 +641,6 @@ public static class BSParam
641 return (b == ConfigurationParameters.numericTrue ? true : false); 641 return (b == ConfigurationParameters.numericTrue ? true : false);
642 } 642 }
643 643
644 private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v)
645 {
646 BSScene physScene = pPhysScene;
647 physScene.TaintedObject("BSParam.ResetBroadphasePoolTainted", delegate()
648 {
649 physScene.PE.ResetBroadphasePool(physScene.World);
650 });
651 }
652
653 private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v)
654 {
655 BSScene physScene = pPhysScene;
656 physScene.TaintedObject("BSParam.ResetConstraintSolver", delegate()
657 {
658 physScene.PE.ResetConstraintSolver(physScene.World);
659 });
660 }
661
662 // Search through the parameter definitions and return the matching 644 // Search through the parameter definitions and return the matching
663 // ParameterDefn structure. 645 // ParameterDefn structure.
664 // Case does not matter as names are compared after converting to lower case. 646 // Case does not matter as names are compared after converting to lower case.
@@ -722,6 +704,22 @@ public static class BSParam
722 } 704 }
723 } 705 }
724 706
707 private static void ResetBroadphasePoolTainted(BSScene pPhysScene, float v)
708 {
709 BSScene physScene = pPhysScene;
710 physScene.TaintedObject("BSParam.ResetBroadphasePoolTainted", delegate()
711 {
712 physScene.PE.ResetBroadphasePool(physScene.World);
713 });
714 }
725 715
716 private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v)
717 {
718 BSScene physScene = pPhysScene;
719 physScene.TaintedObject("BSParam.ResetConstraintSolver", delegate()
720 {
721 physScene.PE.ResetConstraintSolver(physScene.World);
722 });
723 }
726} 724}
727} 725}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 6cd72f2..f8a0c1e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -876,14 +876,39 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
876 // will use the next time since it's pinned and shared memory. 876 // will use the next time since it's pinned and shared memory.
877 // Some of the values require calling into the physics engine to get the new 877 // Some of the values require calling into the physics engine to get the new
878 // value activated ('terrainFriction' for instance). 878 // value activated ('terrainFriction' for instance).
879 public bool SetPhysicsParameter(string parm, float val, uint localID) 879 public bool SetPhysicsParameter(string parm, string val, uint localID)
880 { 880 {
881 bool ret = false; 881 bool ret = false;
882
883 float valf = 0f;
884 if (val.ToLower() == "true")
885 {
886 valf = PhysParameterEntry.NUMERIC_TRUE;
887 }
888 else
889 {
890 if (val.ToLower() == "false")
891 {
892 valf = PhysParameterEntry.NUMERIC_FALSE;
893 }
894 else
895 {
896 try
897 {
898 valf = float.Parse(val);
899 }
900 catch
901 {
902 valf = 0f;
903 }
904 }
905 }
906
882 BSParam.ParameterDefn theParam; 907 BSParam.ParameterDefn theParam;
883 if (BSParam.TryGetParameter(parm, out theParam)) 908 if (BSParam.TryGetParameter(parm, out theParam))
884 { 909 {
885 // Set the value in the C# code 910 // Set the value in the C# code
886 theParam.setter(this, parm, localID, val); 911 theParam.setter(this, parm, localID, valf);
887 912
888 // Optionally set the parameter in the unmanaged code 913 // Optionally set the parameter in the unmanaged code
889 if (theParam.onObject != null) 914 if (theParam.onObject != null)
@@ -898,16 +923,16 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
898 case PhysParameterEntry.APPLY_TO_NONE: 923 case PhysParameterEntry.APPLY_TO_NONE:
899 // This will cause a call into the physical world if some operation is specified (SetOnObject). 924 // This will cause a call into the physical world if some operation is specified (SetOnObject).
900 objectIDs.Add(TERRAIN_ID); 925 objectIDs.Add(TERRAIN_ID);
901 TaintedUpdateParameter(parm, objectIDs, val); 926 TaintedUpdateParameter(parm, objectIDs, valf);
902 break; 927 break;
903 case PhysParameterEntry.APPLY_TO_ALL: 928 case PhysParameterEntry.APPLY_TO_ALL:
904 lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys); 929 lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys);
905 TaintedUpdateParameter(parm, objectIDs, val); 930 TaintedUpdateParameter(parm, objectIDs, valf);
906 break; 931 break;
907 default: 932 default:
908 // setting only one localID 933 // setting only one localID
909 objectIDs.Add(localID); 934 objectIDs.Add(localID);
910 TaintedUpdateParameter(parm, objectIDs, val); 935 TaintedUpdateParameter(parm, objectIDs, valf);
911 break; 936 break;
912 } 937 }
913 } 938 }
@@ -942,14 +967,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
942 967
943 // Get parameter. 968 // Get parameter.
944 // Return 'false' if not able to get the parameter. 969 // Return 'false' if not able to get the parameter.
945 public bool GetPhysicsParameter(string parm, out float value) 970 public bool GetPhysicsParameter(string parm, out string value)
946 { 971 {
947 float val = 0f; 972 string val = String.Empty;
948 bool ret = false; 973 bool ret = false;
949 BSParam.ParameterDefn theParam; 974 BSParam.ParameterDefn theParam;
950 if (BSParam.TryGetParameter(parm, out theParam)) 975 if (BSParam.TryGetParameter(parm, out theParam))
951 { 976 {
952 val = theParam.getter(this); 977 val = theParam.getter(this).ToString();
953 ret = true; 978 ret = true;
954 } 979 }
955 value = val; 980 value = val;
diff --git a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs b/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs
index b8676ba..31a397c 100755
--- a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs
+++ b/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs
@@ -60,14 +60,14 @@ namespace OpenSim.Region.Physics.Manager
60 60
61 // Set parameter on a specific or all instances. 61 // Set parameter on a specific or all instances.
62 // Return 'false' if not able to set the parameter. 62 // Return 'false' if not able to set the parameter.
63 bool SetPhysicsParameter(string parm, float value, uint localID); 63 bool SetPhysicsParameter(string parm, string value, uint localID);
64 64
65 // Get parameter. 65 // Get parameter.
66 // Return 'false' if not able to get the parameter. 66 // Return 'false' if not able to get the parameter.
67 bool GetPhysicsParameter(string parm, out float value); 67 bool GetPhysicsParameter(string parm, out string value);
68 68
69 // Get parameter from a particular object 69 // Get parameter from a particular object
70 // TODO: 70 // TODO:
71 // bool GetPhysicsParameter(string parm, out float value, uint localID); 71 // bool GetPhysicsParameter(string parm, out string value, uint localID);
72 } 72 }
73} 73}