aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/ILlsdMethodHandler.cs13
-rw-r--r--OpenSim/Framework/Servers/LlsdMethod.cs1
-rw-r--r--OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj3
-rw-r--r--OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build1
-rw-r--r--OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs44
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs25
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs20
-rw-r--r--OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj3
-rw-r--r--OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build1
9 files changed, 87 insertions, 24 deletions
diff --git a/OpenSim/Framework/Servers/ILlsdMethodHandler.cs b/OpenSim/Framework/Servers/ILlsdMethodHandler.cs
new file mode 100644
index 0000000..f5daa8d
--- /dev/null
+++ b/OpenSim/Framework/Servers/ILlsdMethodHandler.cs
@@ -0,0 +1,13 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework.Servers
6{
7 public interface ILlsdMethodHandler
8 {
9 string Handle(string request, string path);
10 }
11
12
13}
diff --git a/OpenSim/Framework/Servers/LlsdMethod.cs b/OpenSim/Framework/Servers/LlsdMethod.cs
index c66873f..bf58a71 100644
--- a/OpenSim/Framework/Servers/LlsdMethod.cs
+++ b/OpenSim/Framework/Servers/LlsdMethod.cs
@@ -4,6 +4,5 @@ using System.Text;
4 4
5namespace OpenSim.Framework.Servers 5namespace OpenSim.Framework.Servers
6{ 6{
7 public delegate object LlsdMethod(object request, string path, string param);
8 public delegate TResponse LlsdMethod<TResponse, TRequest>( TRequest request ); 7 public delegate TResponse LlsdMethod<TResponse, TRequest>( TRequest request );
9} 8}
diff --git a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj
index 38d611e..909bd62 100644
--- a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj
+++ b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj
@@ -96,6 +96,9 @@
96 <Compile Include="CheckSumServer.cs"> 96 <Compile Include="CheckSumServer.cs">
97 <SubType>Code</SubType> 97 <SubType>Code</SubType>
98 </Compile> 98 </Compile>
99 <Compile Include="ILlsdMethodHandler.cs">
100 <SubType>Code</SubType>
101 </Compile>
99 <Compile Include="LlsdMethod.cs"> 102 <Compile Include="LlsdMethod.cs">
100 <SubType>Code</SubType> 103 <SubType>Code</SubType>
101 </Compile> 104 </Compile>
diff --git a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build
index 6640a29..22d98dc 100644
--- a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build
+++ b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.dll.build
@@ -13,6 +13,7 @@
13 <sources failonempty="true"> 13 <sources failonempty="true">
14 <include name="BaseHttpServer.cs" /> 14 <include name="BaseHttpServer.cs" />
15 <include name="CheckSumServer.cs" /> 15 <include name="CheckSumServer.cs" />
16 <include name="ILlsdMethodHandler.cs" />
16 <include name="LlsdMethod.cs" /> 17 <include name="LlsdMethod.cs" />
17 <include name="RestMethod.cs" /> 18 <include name="RestMethod.cs" />
18 <include name="UDPServerBase.cs" /> 19 <include name="UDPServerBase.cs" />
diff --git a/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
new file mode 100644
index 0000000..c3d3d33
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
@@ -0,0 +1,44 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Servers;
5using OpenSim.Region.Capabilities;
6using libsecondlife;
7using System.Collections;
8
9namespace OpenSim.Framework.Servers
10{
11 public class LlsdMethodEntry<TResponse, TRequest> : ILlsdMethodHandler
12 where TRequest : new()
13 {
14 private LlsdMethod<TResponse, TRequest> m_method;
15
16
17 public LlsdMethodEntry( )
18 {
19
20 }
21
22 public LlsdMethodEntry(LlsdMethod<TResponse, TRequest> method)
23 {
24 m_method = method;
25 }
26
27 #region ILlsdMethodHandler Members
28
29 public string Handle(string body, string path)
30 {
31 Encoding _enc = System.Text.Encoding.UTF8;
32 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes( body ));
33 TRequest request = new TRequest();
34
35 LLSDHelpers.DeserialiseLLSDMap(hash, request );
36
37 TResponse response = m_method(request);
38
39 return LLSDHelpers.SerialiseLLSDReply( response );
40 }
41
42 #endregion
43 }
44}
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
index 3ba9c77..8e6fd8f 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -17,13 +17,11 @@ namespace SimpleApp
17{ 17{
18 public class MyWorld : Scene 18 public class MyWorld : Scene
19 { 19 {
20 private RegionInfo m_regionInfo;
21 private List<OpenSim.Region.Environment.Scenes.ScenePresence> m_avatars; 20 private List<OpenSim.Region.Environment.Scenes.ScenePresence> m_avatars;
22 21
23 public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) 22 public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
24 : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer) 23 : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer)
25 { 24 {
26 m_regionInfo = regionInfo;
27 m_avatars = new List<Avatar>(); 25 m_avatars = new List<Avatar>();
28 } 26 }
29 27
@@ -68,12 +66,12 @@ namespace SimpleApp
68 66
69 client.OnCompleteMovementToRegion += delegate() 67 client.OnCompleteMovementToRegion += delegate()
70 { 68 {
71 client.MoveAgentIntoRegion(m_regionInfo, pos, LLVector3.Zero ); 69 client.MoveAgentIntoRegion(m_regInfo, pos, LLVector3.Zero );
72 }; 70 };
73 71
74 client.OnCompleteMovementToRegion += delegate() 72 client.OnCompleteMovementToRegion += delegate()
75 { 73 {
76 client.SendAvatarData(m_regionInfo.RegionHandle, client.FirstName, 74 client.SendAvatarData(m_regInfo.RegionHandle, client.FirstName,
77 client.LastName, client.AgentId, 0, 75 client.LastName, client.AgentId, 0,
78 pos, null); 76 pos, null);
79 77
@@ -83,7 +81,7 @@ namespace SimpleApp
83 81
84 }; 82 };
85 83
86 client.SendRegionHandshake(m_regionInfo); 84 client.SendRegionHandshake(m_regInfo);
87 85
88 CreateAndAddScenePresence(client); 86 CreateAndAddScenePresence(client);
89 87
@@ -94,23 +92,6 @@ namespace SimpleApp
94 client.SendWearables( AvatarWearable.DefaultWearables ); 92 client.SendWearables( AvatarWearable.DefaultWearables );
95 } 93 }
96 94
97 public RegionInfo RegionInfo
98 {
99 get { return m_regionInfo; }
100 }
101
102 public object SyncRoot
103 {
104 get { return this; }
105 }
106
107 private uint m_nextLocalId = 1;
108
109 public uint NextLocalId
110 {
111 get { return m_nextLocalId++; }
112 }
113
114 #endregion 95 #endregion
115 } 96 }
116} 97}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index 2c5fb4d..6bf6657 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -64,7 +64,9 @@ namespace SimpleApp
64 udpServer.LocalWorld = world; 64 udpServer.LocalWorld = world;
65 65
66 httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod ); 66 httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod );
67 httpServer.AddLlsdMethod<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo); 67
68 RegisterLlsdHandler<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo);
69
68 httpServer.Start(); 70 httpServer.Start();
69 71
70 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit."); 72 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
@@ -81,7 +83,23 @@ namespace SimpleApp
81 { 83 {
82 return new LLSDMapLayerResponse(); 84 return new LLSDMapLayerResponse();
83 } 85 }
86
87 ILlsdMethodHandler m_handler;
84 88
89 private void RegisterLlsdHandler<TResponse, TRequest>( string path, LlsdMethod<TResponse, TRequest> method )
90 where TRequest : new()
91 {
92 // path should be handler key, but for now just conceptually store it.
93 m_handler = new LlsdMethodEntry<TResponse, TRequest>( method );
94 }
95
96 private string ProcessLlsdMethod( string request,string path )
97 {
98 LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest> concreteHandler = new LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest>( LlsdMethodDemo );
99
100 return m_handler.Handle(request, path);
101 }
102
85 private bool AddNewSessionHandler(ulong regionHandle, Login loginData) 103 private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
86 { 104 {
87 m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last); 105 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 3ed0efc..1e726b2 100644
--- a/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj
+++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.csproj
@@ -154,6 +154,9 @@
154 </ProjectReference> 154 </ProjectReference>
155 </ItemGroup> 155 </ItemGroup>
156 <ItemGroup> 156 <ItemGroup>
157 <Compile Include="LlsdMethodEntry.cs">
158 <SubType>Code</SubType>
159 </Compile>
157 <Compile Include="MyWorld.cs"> 160 <Compile Include="MyWorld.cs">
158 <SubType>Code</SubType> 161 <SubType>Code</SubType>
159 </Compile> 162 </Compile>
diff --git a/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build
index 0c6234a..a826a37 100644
--- a/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build
+++ b/OpenSim/Region/Examples/SimpleApp/SimpleApp.exe.build
@@ -11,6 +11,7 @@
11 <resources prefix="SimpleApp" dynamicprefix="true" > 11 <resources prefix="SimpleApp" dynamicprefix="true" >
12 </resources> 12 </resources>
13 <sources failonempty="true"> 13 <sources failonempty="true">
14 <include name="LlsdMethodEntry.cs" />
14 <include name="MyWorld.cs" /> 15 <include name="MyWorld.cs" />
15 <include name="Program.cs" /> 16 <include name="Program.cs" />
16 <include name="Properties/AssemblyInfo.cs" /> 17 <include name="Properties/AssemblyInfo.cs" />