Add an event and some logic to allow customizing Simulator Features by avatar
parent
4c7df6a147
commit
32c4e1a850
|
@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
// private static readonly ILog m_log =
|
// private static readonly ILog m_log =
|
||||||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
|
||||||
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -158,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
IRequestHandler reqHandler
|
IRequestHandler reqHandler
|
||||||
= new RestHTTPHandler(
|
= new RestHTTPHandler(
|
||||||
"GET", "/CAPS/" + UUID.Random(),
|
"GET", "/CAPS/" + UUID.Random(),
|
||||||
HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString());
|
x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString());
|
||||||
|
|
||||||
caps.RegisterHandler("SimulatorFeatures", reqHandler);
|
caps.RegisterHandler("SimulatorFeatures", reqHandler);
|
||||||
}
|
}
|
||||||
|
@ -187,18 +189,33 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
return new OSDMap(m_features);
|
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");
|
// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request");
|
||||||
|
|
||||||
|
OSDMap copy = DeepCopy();
|
||||||
|
|
||||||
|
SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest;
|
||||||
|
if (handlerOnSimulatorFeaturesRequest != null)
|
||||||
|
handlerOnSimulatorFeaturesRequest(agentID, ref copy);
|
||||||
|
|
||||||
//Send back data
|
//Send back data
|
||||||
Hashtable responsedata = new Hashtable();
|
Hashtable responsedata = new Hashtable();
|
||||||
responsedata["int_response_code"] = 200;
|
responsedata["int_response_code"] = 200;
|
||||||
responsedata["content_type"] = "text/plain";
|
responsedata["content_type"] = "text/plain";
|
||||||
responsedata["keepalive"] = false;
|
responsedata["keepalive"] = false;
|
||||||
|
|
||||||
lock (m_features)
|
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy);
|
||||||
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features);
|
|
||||||
|
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,15 +26,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
|
|
||||||
namespace OpenSim.Region.Framework.Interfaces
|
namespace OpenSim.Region.Framework.Interfaces
|
||||||
{
|
{
|
||||||
|
public delegate void SimulatorFeaturesRequestDelegate(UUID agentID, ref OSDMap features);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability.
|
/// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISimulatorFeaturesModule
|
public interface ISimulatorFeaturesModule
|
||||||
{
|
{
|
||||||
|
event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
|
||||||
void AddFeature(string name, OSD value);
|
void AddFeature(string name, OSD value);
|
||||||
bool RemoveFeature(string name);
|
bool RemoveFeature(string name);
|
||||||
bool TryGetFeature(string name, out OSD value);
|
bool TryGetFeature(string name, out OSD value);
|
||||||
|
|
Loading…
Reference in New Issue