* Completed conceptual LlsdMethod - everything resides in SimpleApp pending guru approval.

Sugilite
lbsa71 2007-07-03 07:06:08 +00:00
parent 315a49e7fd
commit 73a5ec391a
9 changed files with 87 additions and 24 deletions

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Servers
{
public interface ILlsdMethodHandler
{
string Handle(string request, string path);
}
}

View File

@ -4,6 +4,5 @@ using System.Text;
namespace OpenSim.Framework.Servers
{
public delegate object LlsdMethod(object request, string path, string param);
public delegate TResponse LlsdMethod<TResponse, TRequest>( TRequest request );
}

View File

@ -96,6 +96,9 @@
<Compile Include="CheckSumServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ILlsdMethodHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LlsdMethod.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -13,6 +13,7 @@
<sources failonempty="true">
<include name="BaseHttpServer.cs" />
<include name="CheckSumServer.cs" />
<include name="ILlsdMethodHandler.cs" />
<include name="LlsdMethod.cs" />
<include name="RestMethod.cs" />
<include name="UDPServerBase.cs" />

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Servers;
using OpenSim.Region.Capabilities;
using libsecondlife;
using System.Collections;
namespace OpenSim.Framework.Servers
{
public class LlsdMethodEntry<TResponse, TRequest> : ILlsdMethodHandler
where TRequest : new()
{
private LlsdMethod<TResponse, TRequest> m_method;
public LlsdMethodEntry( )
{
}
public LlsdMethodEntry(LlsdMethod<TResponse, TRequest> method)
{
m_method = method;
}
#region ILlsdMethodHandler Members
public string Handle(string body, string path)
{
Encoding _enc = System.Text.Encoding.UTF8;
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes( body ));
TRequest request = new TRequest();
LLSDHelpers.DeserialiseLLSDMap(hash, request );
TResponse response = m_method(request);
return LLSDHelpers.SerialiseLLSDReply( response );
}
#endregion
}
}

View File

@ -17,13 +17,11 @@ namespace SimpleApp
{
public class MyWorld : Scene
{
private RegionInfo m_regionInfo;
private List<OpenSim.Region.Environment.Scenes.ScenePresence> m_avatars;
public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
: base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer)
{
m_regionInfo = regionInfo;
m_avatars = new List<Avatar>();
}
@ -68,12 +66,12 @@ namespace SimpleApp
client.OnCompleteMovementToRegion += delegate()
{
client.MoveAgentIntoRegion(m_regionInfo, pos, LLVector3.Zero );
client.MoveAgentIntoRegion(m_regInfo, pos, LLVector3.Zero );
};
client.OnCompleteMovementToRegion += delegate()
{
client.SendAvatarData(m_regionInfo.RegionHandle, client.FirstName,
client.SendAvatarData(m_regInfo.RegionHandle, client.FirstName,
client.LastName, client.AgentId, 0,
pos, null);
@ -83,7 +81,7 @@ namespace SimpleApp
};
client.SendRegionHandshake(m_regionInfo);
client.SendRegionHandshake(m_regInfo);
CreateAndAddScenePresence(client);
@ -94,23 +92,6 @@ namespace SimpleApp
client.SendWearables( AvatarWearable.DefaultWearables );
}
public RegionInfo RegionInfo
{
get { return m_regionInfo; }
}
public object SyncRoot
{
get { return this; }
}
private uint m_nextLocalId = 1;
public uint NextLocalId
{
get { return m_nextLocalId++; }
}
#endregion
}
}

View File

@ -64,7 +64,9 @@ namespace SimpleApp
udpServer.LocalWorld = world;
httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod );
httpServer.AddLlsdMethod<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo);
RegisterLlsdHandler<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo);
httpServer.Start();
m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
@ -81,7 +83,23 @@ namespace SimpleApp
{
return new LLSDMapLayerResponse();
}
ILlsdMethodHandler m_handler;
private void RegisterLlsdHandler<TResponse, TRequest>( string path, LlsdMethod<TResponse, TRequest> method )
where TRequest : new()
{
// path should be handler key, but for now just conceptually store it.
m_handler = new LlsdMethodEntry<TResponse, TRequest>( method );
}
private string ProcessLlsdMethod( string request,string path )
{
LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest> concreteHandler = new LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest>( LlsdMethodDemo );
return m_handler.Handle(request, path);
}
private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
{
m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);

View File

@ -154,6 +154,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="LlsdMethodEntry.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MyWorld.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -11,6 +11,7 @@
<resources prefix="SimpleApp" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="LlsdMethodEntry.cs" />
<include name="MyWorld.cs" />
<include name="Program.cs" />
<include name="Properties/AssemblyInfo.cs" />