From 73a5ec391aa5600cb779044fbf335ce0537e9500 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Jul 2007 07:06:08 +0000 Subject: [PATCH] * Completed conceptual LlsdMethod - everything resides in SimpleApp pending guru approval. --- .../Framework/Servers/ILlsdMethodHandler.cs | 13 ++++++ OpenSim/Framework/Servers/LlsdMethod.cs | 1 - .../Servers/OpenSim.Framework.Servers.csproj | 3 ++ .../OpenSim.Framework.Servers.dll.build | 1 + .../Examples/SimpleApp/LlsdMethodEntry.cs | 44 +++++++++++++++++++ OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 25 ++--------- OpenSim/Region/Examples/SimpleApp/Program.cs | 20 ++++++++- .../Examples/SimpleApp/SimpleApp.csproj | 3 ++ .../Examples/SimpleApp/SimpleApp.exe.build | 1 + 9 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 OpenSim/Framework/Servers/ILlsdMethodHandler.cs create mode 100644 OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs diff --git a/OpenSim/Framework/Servers/ILlsdMethodHandler.cs b/OpenSim/Framework/Servers/ILlsdMethodHandler.cs new file mode 100644 index 0000000000..f5daa8dbdd --- /dev/null +++ b/OpenSim/Framework/Servers/ILlsdMethodHandler.cs @@ -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); + } + + +} diff --git a/OpenSim/Framework/Servers/LlsdMethod.cs b/OpenSim/Framework/Servers/LlsdMethod.cs index c66873fe6b..bf58a71970 100644 --- a/OpenSim/Framework/Servers/LlsdMethod.cs +++ b/OpenSim/Framework/Servers/LlsdMethod.cs @@ -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( TRequest request ); } diff --git a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj index 38d611e8dc..909bd622b6 100644 --- a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj +++ b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj @@ -96,6 +96,9 @@ Code + + Code + Code diff --git a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build index 6640a29b79..22d98dc5e4 100644 --- a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build +++ b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build @@ -13,6 +13,7 @@ + diff --git a/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs new file mode 100644 index 0000000000..c3d3d338de --- /dev/null +++ b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs @@ -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 : ILlsdMethodHandler + where TRequest : new() + { + private LlsdMethod m_method; + + + public LlsdMethodEntry( ) + { + + } + + public LlsdMethodEntry(LlsdMethod 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 + } +} diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 3ba9c77c24..8e6fd8f4b7 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs @@ -17,13 +17,11 @@ namespace SimpleApp { public class MyWorld : Scene { - private RegionInfo m_regionInfo; private List m_avatars; public MyWorld(Dictionary 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(); } @@ -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 } } diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 2c5fb4d11f..6bf6657299 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -64,7 +64,9 @@ namespace SimpleApp udpServer.LocalWorld = world; httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod ); - httpServer.AddLlsdMethod("/Caps/test/", LlsdMethodDemo); + + RegisterLlsdHandler("/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( string path, LlsdMethod method ) + where TRequest : new() + { + // path should be handler key, but for now just conceptually store it. + m_handler = new LlsdMethodEntry( method ); + } + + private string ProcessLlsdMethod( string request,string path ) + { + LlsdMethodEntry concreteHandler = new LlsdMethodEntry( 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); diff --git a/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj b/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj index 3ed0efc949..1e726b20e5 100644 --- a/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj +++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj @@ -154,6 +154,9 @@ + + Code + Code diff --git a/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build index 0c6234a5c6..a826a37a3f 100644 --- a/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build +++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build @@ -11,6 +11,7 @@ +