change SimulatorFeaturesModule
parent
830b034b81
commit
0348c01ce7
|
@ -129,10 +129,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
public void RegisterCaps(UUID agentID, Caps caps)
|
public void RegisterCaps(UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
string capUrl = "/CAPS/" + UUID.Random() + "/";
|
|
||||||
|
|
||||||
caps.RegisterSimpleHandler("EstateChangeInfo",
|
caps.RegisterSimpleHandler("EstateChangeInfo",
|
||||||
new SimpleStreamHandler("/CAPS/" + UUID.Random(), delegate (IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
new SimpleStreamHandler("/" + UUID.Random(), delegate (IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
ProcessRequest(httpRequest, httpResponse, agentID, caps);
|
ProcessRequest(httpRequest, httpResponse, agentID, caps);
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -29,6 +29,7 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -81,7 +82,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
static private object m_scriptSyntaxLock = new object();
|
static private object m_scriptSyntaxLock = new object();
|
||||||
static private UUID m_scriptSyntaxID = UUID.Zero;
|
static private UUID m_scriptSyntaxID = UUID.Zero;
|
||||||
static private string m_scriptSyntaxXML;
|
static private byte[] m_scriptSyntaxXML = null;
|
||||||
|
|
||||||
#region ISharedRegionModule Members
|
#region ISharedRegionModule Members
|
||||||
|
|
||||||
|
@ -214,19 +215,17 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
public void RegisterCaps(UUID agentID, Caps caps)
|
public void RegisterCaps(UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
IRequestHandler reqHandler = new RestHTTPHandler(
|
caps.RegisterSimpleHandler("SimulatorFeatures",
|
||||||
"GET", "/CAPS/" + UUID.Random(),
|
new SimpleStreamHandler("/" + UUID.Random() + "/",
|
||||||
x => { return HandleSimulatorFeaturesRequest(x, agentID); },
|
delegate (IOSHttpRequest request, IOSHttpResponse response)
|
||||||
"SimulatorFeatures", agentID.ToString());
|
|
||||||
caps.RegisterHandler("SimulatorFeatures", reqHandler);
|
|
||||||
|
|
||||||
if (m_doScriptSyntax && m_scriptSyntaxID != UUID.Zero && !String.IsNullOrEmpty(m_scriptSyntaxXML))
|
|
||||||
{
|
{
|
||||||
IRequestHandler sreqHandler = new RestHTTPHandler(
|
HandleSimulatorFeaturesRequest(request, response, agentID);
|
||||||
"GET", "/CAPS/" + UUID.Random(),
|
}));
|
||||||
x => { return HandleSyntaxRequest(x, agentID); },
|
|
||||||
"LSLSyntax", agentID.ToString());
|
if (m_doScriptSyntax && m_scriptSyntaxID != UUID.Zero && m_scriptSyntaxXML != null)
|
||||||
caps.RegisterHandler("LSLSyntax", sreqHandler);
|
{
|
||||||
|
caps.RegisterSimpleHandler("LSLSyntax",
|
||||||
|
new SimpleStreamHandler("/" + UUID.Random() + "/", HandleSyntaxRequest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,36 +263,38 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
return (OSDMap)copy;
|
return (OSDMap)copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID)
|
private void HandleSimulatorFeaturesRequest(IOSHttpRequest request, IOSHttpResponse response, UUID agentID)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request");
|
// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request");
|
||||||
|
|
||||||
|
if (request.HttpMethod != "GET")
|
||||||
|
{
|
||||||
|
response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OSDMap copy = DeepCopy();
|
OSDMap copy = DeepCopy();
|
||||||
|
|
||||||
// Let's add the agentID to the destination guide, if it is expecting that.
|
// Let's add the agentID to the destination guide, if it is expecting that.
|
||||||
if (copy.ContainsKey("OpenSimExtras") && ((OSDMap)(copy["OpenSimExtras"])).ContainsKey("destination-guide-url"))
|
if (copy.ContainsKey("OpenSimExtras") && ((OSDMap)(copy["OpenSimExtras"])).ContainsKey("destination-guide-url"))
|
||||||
((OSDMap)copy["OpenSimExtras"])["destination-guide-url"] = Replace(((OSDMap)copy["OpenSimExtras"])["destination-guide-url"], "[USERID]", agentID.ToString());
|
((OSDMap)copy["OpenSimExtras"])["destination-guide-url"] = Replace(((OSDMap)copy["OpenSimExtras"])["destination-guide-url"], "[USERID]", agentID.ToString());
|
||||||
|
|
||||||
SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest;
|
OnSimulatorFeaturesRequest?.Invoke(agentID, ref copy);
|
||||||
|
|
||||||
if (handlerOnSimulatorFeaturesRequest != null)
|
|
||||||
handlerOnSimulatorFeaturesRequest(agentID, ref copy);
|
|
||||||
|
|
||||||
//Send back data
|
//Send back data
|
||||||
Hashtable responsedata = new Hashtable();
|
response.RawBuffer = Util.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(copy));
|
||||||
responsedata["int_response_code"] = 200;
|
response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
responsedata["content_type"] = "text/plain";
|
|
||||||
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy);
|
|
||||||
|
|
||||||
return responsedata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Hashtable HandleSyntaxRequest(Hashtable mDhttpMethod, UUID agentID)
|
private void HandleSyntaxRequest(IOSHttpRequest request, IOSHttpResponse response)
|
||||||
{
|
{
|
||||||
Hashtable responsedata = new Hashtable();
|
if (request.HttpMethod != "GET" || m_scriptSyntaxXML == null)
|
||||||
responsedata["int_response_code"] = 200;
|
{
|
||||||
responsedata["str_response_string"] = m_scriptSyntaxXML;
|
response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
return responsedata;
|
return;
|
||||||
|
}
|
||||||
|
response.RawBuffer = m_scriptSyntaxXML;
|
||||||
|
response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -372,7 +373,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
continue;
|
continue;
|
||||||
sb.Append(s);
|
sb.Append(s);
|
||||||
}
|
}
|
||||||
m_scriptSyntaxXML = sb.ToString();
|
m_scriptSyntaxXML = Util.UTF8.GetBytes(sb.ToString());
|
||||||
m_scriptSyntaxID = id;
|
m_scriptSyntaxID = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,7 +381,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
{
|
{
|
||||||
m_log.Error("[SIMULATOR FEATURES MODULE] fail read ScriptSyntax.xml file");
|
m_log.Error("[SIMULATOR FEATURES MODULE] fail read ScriptSyntax.xml file");
|
||||||
m_scriptSyntaxID = UUID.Zero;
|
m_scriptSyntaxID = UUID.Zero;
|
||||||
m_scriptSyntaxXML = "";
|
m_scriptSyntaxXML = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue