* 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 namespace OpenSim.Framework.Servers
{ {
public delegate object LlsdMethod(object request, string path, string param);
public delegate TResponse LlsdMethod<TResponse, TRequest>( TRequest request ); public delegate TResponse LlsdMethod<TResponse, TRequest>( TRequest request );
} }

View File

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

View File

@ -13,6 +13,7 @@
<sources failonempty="true"> <sources failonempty="true">
<include name="BaseHttpServer.cs" /> <include name="BaseHttpServer.cs" />
<include name="CheckSumServer.cs" /> <include name="CheckSumServer.cs" />
<include name="ILlsdMethodHandler.cs" />
<include name="LlsdMethod.cs" /> <include name="LlsdMethod.cs" />
<include name="RestMethod.cs" /> <include name="RestMethod.cs" />
<include name="UDPServerBase.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 public class MyWorld : Scene
{ {
private RegionInfo m_regionInfo;
private List<OpenSim.Region.Environment.Scenes.ScenePresence> m_avatars; 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) public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
: base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer) : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer)
{ {
m_regionInfo = regionInfo;
m_avatars = new List<Avatar>(); m_avatars = new List<Avatar>();
} }
@ -68,12 +66,12 @@ namespace SimpleApp
client.OnCompleteMovementToRegion += delegate() client.OnCompleteMovementToRegion += delegate()
{ {
client.MoveAgentIntoRegion(m_regionInfo, pos, LLVector3.Zero ); client.MoveAgentIntoRegion(m_regInfo, pos, LLVector3.Zero );
}; };
client.OnCompleteMovementToRegion += delegate() client.OnCompleteMovementToRegion += delegate()
{ {
client.SendAvatarData(m_regionInfo.RegionHandle, client.FirstName, client.SendAvatarData(m_regInfo.RegionHandle, client.FirstName,
client.LastName, client.AgentId, 0, client.LastName, client.AgentId, 0,
pos, null); pos, null);
@ -83,7 +81,7 @@ namespace SimpleApp
}; };
client.SendRegionHandshake(m_regionInfo); client.SendRegionHandshake(m_regInfo);
CreateAndAddScenePresence(client); CreateAndAddScenePresence(client);
@ -94,23 +92,6 @@ namespace SimpleApp
client.SendWearables( AvatarWearable.DefaultWearables ); 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 #endregion
} }
} }

View File

@ -64,7 +64,9 @@ namespace SimpleApp
udpServer.LocalWorld = world; udpServer.LocalWorld = world;
httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod ); httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod );
httpServer.AddLlsdMethod<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo);
RegisterLlsdHandler<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo);
httpServer.Start(); httpServer.Start();
m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit."); m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
@ -81,7 +83,23 @@ namespace SimpleApp
{ {
return new LLSDMapLayerResponse(); 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) private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
{ {
m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last); m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);

View File

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

View File

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