mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
* Completed conceptual LlsdMethod - everything resides in SimpleApp pending guru approval.
This commit is contained in:
44
OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
Normal file
44
OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -154,6 +154,9 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LlsdMethodEntry.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MyWorld.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user