diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 191bccf..6ef8815 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | |||
@@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
59 | // private static readonly ILog m_log = | 59 | // private static readonly ILog m_log = |
60 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 60 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
61 | 61 | ||
62 | public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; | ||
63 | |||
62 | private Scene m_scene; | 64 | private Scene m_scene; |
63 | 65 | ||
64 | /// <summary> | 66 | /// <summary> |
@@ -94,6 +96,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
94 | { | 96 | { |
95 | m_scene = s; | 97 | m_scene = s; |
96 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 98 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
99 | |||
100 | m_scene.RegisterModuleInterface<ISimulatorFeaturesModule>(this); | ||
97 | } | 101 | } |
98 | 102 | ||
99 | public void RemoveRegion(Scene s) | 103 | public void RemoveRegion(Scene s) |
@@ -156,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
156 | IRequestHandler reqHandler | 160 | IRequestHandler reqHandler |
157 | = new RestHTTPHandler( | 161 | = new RestHTTPHandler( |
158 | "GET", "/CAPS/" + UUID.Random(), | 162 | "GET", "/CAPS/" + UUID.Random(), |
159 | HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString()); | 163 | x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString()); |
160 | 164 | ||
161 | caps.RegisterHandler("SimulatorFeatures", reqHandler); | 165 | caps.RegisterHandler("SimulatorFeatures", reqHandler); |
162 | } | 166 | } |
@@ -185,18 +189,33 @@ namespace OpenSim.Region.ClientStack.Linden | |||
185 | return new OSDMap(m_features); | 189 | return new OSDMap(m_features); |
186 | } | 190 | } |
187 | 191 | ||
188 | private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) | 192 | private OSDMap DeepCopy() |
193 | { | ||
194 | // This isn't the cheapest way of doing this but the rate | ||
195 | // of occurrence is low (on sim entry only) and it's a sure | ||
196 | // way to get a true deep copy. | ||
197 | OSD copy = OSDParser.DeserializeLLSDXml(OSDParser.SerializeLLSDXmlString(m_features)); | ||
198 | |||
199 | return (OSDMap)copy; | ||
200 | } | ||
201 | |||
202 | private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID) | ||
189 | { | 203 | { |
190 | // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); | 204 | // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); |
191 | 205 | ||
206 | OSDMap copy = DeepCopy(); | ||
207 | |||
208 | SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; | ||
209 | if (handlerOnSimulatorFeaturesRequest != null) | ||
210 | handlerOnSimulatorFeaturesRequest(agentID, ref copy); | ||
211 | |||
192 | //Send back data | 212 | //Send back data |
193 | Hashtable responsedata = new Hashtable(); | 213 | Hashtable responsedata = new Hashtable(); |
194 | responsedata["int_response_code"] = 200; | 214 | responsedata["int_response_code"] = 200; |
195 | responsedata["content_type"] = "text/plain"; | 215 | responsedata["content_type"] = "text/plain"; |
196 | responsedata["keepalive"] = false; | 216 | responsedata["keepalive"] = false; |
197 | 217 | ||
198 | lock (m_features) | 218 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy); |
199 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features); | ||
200 | 219 | ||
201 | return responsedata; | 220 | return responsedata; |
202 | } | 221 | } |