From 5c32b33a66fbdf371d53d85ee54ee8e837481570 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 4 Jul 2007 16:28:59 +0000 Subject: * re-fixed the utf-16 bug in xmlRpcResponse serialization * added LLSDStreamHandler.cs to Caps (Haven't enabled it yet, though) * removed last traces of old rest handling --- OpenSim/Region/Capabilities/Caps.cs | 38 +++++++++++++------- OpenSim/Region/Capabilities/LLSDMethod.cs | 8 +++++ OpenSim/Region/Capabilities/LLSDStreamHandler.cs | 40 ++++++++++++++++++++++ .../OpenSim.Region.Capabilities.csproj | 6 ++++ .../OpenSim.Region.Capabilities.dll.build | 2 ++ 5 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 OpenSim/Region/Capabilities/LLSDMethod.cs create mode 100644 OpenSim/Region/Capabilities/LLSDStreamHandler.cs (limited to 'OpenSim/Region/Capabilities') diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 1d07683..70d601f 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -71,20 +71,33 @@ namespace OpenSim.Region.Capabilities public void RegisterHandlers() { Console.WriteLine("registering CAPS handlers"); + string capsBase = "/CAPS/" + m_capsObjectPath; + + AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); + + //httpListener.AddStreamHandler( + // new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); - AddCapsHandler( httpListener, m_requestPath, CapsRequest); - AddCapsHandler( httpListener, m_mapLayerPath, MapLayer); - AddCapsHandler( httpListener, m_newInventory, NewAgentInventory); - AddCapsHandler( httpListener, eventQueue, ProcessEventQueue); - AddCapsHandler( httpListener, m_requestTexture, RequestTexture); + AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); + AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory); + AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue); + AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture); } - private void AddCapsHandler( BaseHttpServer httpListener, string path, RestMethod restMethod ) + public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) + { + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); + mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); + return mapResponse; + } + + [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] + private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { string capsBase = "/CAPS/" + m_capsObjectPath; httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } - + /// /// /// @@ -125,17 +138,18 @@ namespace OpenSim.Region.Capabilities public string MapLayer(string request, string path, string param) { Encoding _enc = Encoding.UTF8; - Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request)); + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes(request)); LLSDMapRequest mapReq = new LLSDMapRequest(); - LLSDHelpers.DeserialiseLLSDMap(hash, mapReq ); + LLSDHelpers.DeserialiseLLSDMap(hash, mapReq); - LLSDMapLayerResponse mapResponse= new LLSDMapLayerResponse(); + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); string res = LLSDHelpers.SerialiseLLSDReply(mapResponse); - + return res; } + /// /// /// @@ -214,7 +228,7 @@ namespace OpenSim.Region.Capabilities string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); - AddCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps); + AddLegacyCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + uploaderPath; //Console.WriteLine("uploader url is " + uploaderURL); diff --git a/OpenSim/Region/Capabilities/LLSDMethod.cs b/OpenSim/Region/Capabilities/LLSDMethod.cs new file mode 100644 index 0000000..5f42f44 --- /dev/null +++ b/OpenSim/Region/Capabilities/LLSDMethod.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Capabilities +{ + public delegate TResponse LLSDMethod(TRequest request); +} diff --git a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs new file mode 100644 index 0000000..ff63353 --- /dev/null +++ b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Servers; +using System.IO; +using System.Collections; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + public class LLSDStreamhandler : BaseStreamHandler + where TRequest : new() + { + private LLSDMethod m_method; + + public LLSDStreamhandler(string httpMethod, string path, LLSDMethod method) + : base(httpMethod, path) + { + m_method = method; + } + + public override byte[] Handle(string path, Stream request) + { + Encoding encoding = Encoding.UTF8; + StreamReader streamReader = new StreamReader(request, encoding); + + string requestBody = streamReader.ReadToEnd(); + streamReader.Close(); + + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(encoding.GetBytes(requestBody)); + TRequest llsdRequest = new TRequest(); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + + TResponse response = m_method(llsdRequest); + + return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) ); + + } + } +} diff --git a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj index 4667d52..4b672ae 100644 --- a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj +++ b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj @@ -123,6 +123,12 @@ Code + + Code + + + Code + Code diff --git a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build index a091b5c..1d552c2 100644 --- a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build +++ b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build @@ -20,6 +20,8 @@ + + -- cgit v1.1