* LLSDStreamhandler now works.

Sugilite
lbsa71 2007-07-09 23:32:29 +00:00
parent 19c01bfb52
commit 9f5f65c847
4 changed files with 20 additions and 18 deletions

View File

@ -31,7 +31,7 @@ namespace OpenSim.Framework.Servers
public abstract byte[] Handle(string path, Stream request);
protected BaseStreamHandler(string path, string httpMethod )
protected BaseStreamHandler(string httpMethod, string path)
{
m_httpMethod = httpMethod;
m_path = path;

View File

@ -23,7 +23,7 @@ namespace OpenSim.Framework.Servers
return Encoding.UTF8.GetBytes(responseString);
}
public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( path, httpMethod )
public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path )
{
m_restMethod = restMethod;
}

View File

@ -74,10 +74,10 @@ namespace OpenSim.Region.Capabilities
string capsBase = "/CAPS/" + m_capsObjectPath;
AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer);
//AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer);
//httpListener.AddStreamHandler(
// new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer ));
httpListener.AddStreamHandler(
new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer ));
AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory);
@ -86,13 +86,6 @@ namespace OpenSim.Region.Capabilities
}
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)
{
@ -151,6 +144,13 @@ namespace OpenSim.Region.Capabilities
return res;
}
public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
{
LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse());
return mapResponse;
}
/// <summary>
///

View File

@ -14,25 +14,27 @@ namespace OpenSim.Region.Capabilities
private LLSDMethod<TRequest, TResponse> m_method;
public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
: base(httpMethod, path)
: base(httpMethod, path )
{
m_method = method;
}
public override byte[] Handle(string path, Stream request)
{
Encoding encoding = Encoding.UTF8;
StreamReader streamReader = new StreamReader(request, encoding);
//Encoding encoding = Encoding.UTF8;
//StreamReader streamReader = new StreamReader(request, false);
string requestBody = streamReader.ReadToEnd();
streamReader.Close();
//string requestBody = streamReader.ReadToEnd();
//streamReader.Close();
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(encoding.GetBytes(requestBody));
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request );
TRequest llsdRequest = new TRequest();
LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
TResponse response = m_method(llsdRequest);
Encoding encoding = new UTF8Encoding(false);
return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) );
}