Merge branch 'avination' into careminster

avinationmerge
Melanie 2013-02-14 09:12:27 +00:00
commit a5a56a8755
2 changed files with 26 additions and 5 deletions

View File

@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.Linden
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
private Scene m_scene;
/// <summary>
@ -158,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden
IRequestHandler reqHandler
= new RestHTTPHandler(
"GET", "/CAPS/" + UUID.Random(),
HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString());
x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString());
caps.RegisterHandler("SimulatorFeatures", reqHandler);
}
@ -187,18 +189,33 @@ namespace OpenSim.Region.ClientStack.Linden
return new OSDMap(m_features);
}
private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod)
private OSDMap DeepCopy()
{
// This isn't the cheapest way of doing this but the rate
// of occurrence is low (on sim entry only) and it's a sure
// way to get a true deep copy.
OSD copy = OSDParser.DeserializeLLSDXml(OSDParser.SerializeLLSDXmlString(m_features));
return (OSDMap)copy;
}
private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID)
{
// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request");
OSDMap copy = DeepCopy();
SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest;
if (handlerOnSimulatorFeaturesRequest != null)
handlerOnSimulatorFeaturesRequest(agentID, ref copy);
//Send back data
Hashtable responsedata = new Hashtable();
responsedata["int_response_code"] = 200;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
lock (m_features)
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features);
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy);
return responsedata;
}

View File

@ -26,15 +26,19 @@
*/
using System;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Region.Framework.Interfaces
{
public delegate void SimulatorFeaturesRequestDelegate(UUID agentID, ref OSDMap features);
/// <summary>
/// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability.
/// </summary>
public interface ISimulatorFeaturesModule
{
event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
void AddFeature(string name, OSD value);
bool RemoveFeature(string name);
bool TryGetFeature(string name, out OSD value);