aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Capabilities/Caps.cs38
-rw-r--r--OpenSim/Region/Capabilities/LLSDMethod.cs8
-rw-r--r--OpenSim/Region/Capabilities/LLSDStreamHandler.cs40
-rw-r--r--OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj6
-rw-r--r--OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build2
-rw-r--r--OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs35
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs23
7 files changed, 84 insertions, 68 deletions
diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs
index 1d07683..70d601f 100644
--- a/OpenSim/Region/Capabilities/Caps.cs
+++ b/OpenSim/Region/Capabilities/Caps.cs
@@ -71,20 +71,33 @@ namespace OpenSim.Region.Capabilities
71 public void RegisterHandlers() 71 public void RegisterHandlers()
72 { 72 {
73 Console.WriteLine("registering CAPS handlers"); 73 Console.WriteLine("registering CAPS handlers");
74 string capsBase = "/CAPS/" + m_capsObjectPath;
75
76 AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer);
77
78 //httpListener.AddStreamHandler(
79 // new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer ));
74 80
75 AddCapsHandler( httpListener, m_requestPath, CapsRequest); 81 AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
76 AddCapsHandler( httpListener, m_mapLayerPath, MapLayer); 82 AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory);
77 AddCapsHandler( httpListener, m_newInventory, NewAgentInventory); 83 AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue);
78 AddCapsHandler( httpListener, eventQueue, ProcessEventQueue); 84 AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture);
79 AddCapsHandler( httpListener, m_requestTexture, RequestTexture);
80 } 85 }
81 86
82 private void AddCapsHandler( BaseHttpServer httpListener, string path, RestMethod restMethod ) 87 public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
88 {
89 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
90 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse());
91 return mapResponse;
92 }
93
94 [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")]
95 private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod)
83 { 96 {
84 string capsBase = "/CAPS/" + m_capsObjectPath; 97 string capsBase = "/CAPS/" + m_capsObjectPath;
85 httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); 98 httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
86 } 99 }
87 100
88 /// <summary> 101 /// <summary>
89 /// 102 ///
90 /// </summary> 103 /// </summary>
@@ -125,17 +138,18 @@ namespace OpenSim.Region.Capabilities
125 public string MapLayer(string request, string path, string param) 138 public string MapLayer(string request, string path, string param)
126 { 139 {
127 Encoding _enc = Encoding.UTF8; 140 Encoding _enc = Encoding.UTF8;
128 Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request)); 141 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes(request));
129 LLSDMapRequest mapReq = new LLSDMapRequest(); 142 LLSDMapRequest mapReq = new LLSDMapRequest();
130 LLSDHelpers.DeserialiseLLSDMap(hash, mapReq ); 143 LLSDHelpers.DeserialiseLLSDMap(hash, mapReq);
131 144
132 LLSDMapLayerResponse mapResponse= new LLSDMapLayerResponse(); 145 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
133 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); 146 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse());
134 string res = LLSDHelpers.SerialiseLLSDReply(mapResponse); 147 string res = LLSDHelpers.SerialiseLLSDReply(mapResponse);
135 148
136 return res; 149 return res;
137 } 150 }
138 151
152
139 /// <summary> 153 /// <summary>
140 /// 154 ///
141 /// </summary> 155 /// </summary>
@@ -214,7 +228,7 @@ namespace OpenSim.Region.Capabilities
214 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 228 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
215 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); 229 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener);
216 230
217 AddCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps); 231 AddLegacyCapsHandler( httpListener, uploaderPath, uploader.uploaderCaps);
218 232
219 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + uploaderPath; 233 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + uploaderPath;
220 //Console.WriteLine("uploader url is " + uploaderURL); 234 //Console.WriteLine("uploader url is " + uploaderURL);
diff --git a/OpenSim/Region/Capabilities/LLSDMethod.cs b/OpenSim/Region/Capabilities/LLSDMethod.cs
new file mode 100644
index 0000000..5f42f44
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDMethod.cs
@@ -0,0 +1,8 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Capabilities
6{
7 public delegate TResponse LLSDMethod<TRequest, TResponse>(TRequest request);
8}
diff --git a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs
new file mode 100644
index 0000000..ff63353
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs
@@ -0,0 +1,40 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Servers;
5using System.IO;
6using System.Collections;
7using libsecondlife;
8
9namespace OpenSim.Region.Capabilities
10{
11 public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler
12 where TRequest : new()
13 {
14 private LLSDMethod<TRequest, TResponse> m_method;
15
16 public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
17 : base(httpMethod, path)
18 {
19 m_method = method;
20 }
21
22 public override byte[] Handle(string path, Stream request)
23 {
24 Encoding encoding = Encoding.UTF8;
25 StreamReader streamReader = new StreamReader(request, encoding);
26
27 string requestBody = streamReader.ReadToEnd();
28 streamReader.Close();
29
30 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(encoding.GetBytes(requestBody));
31 TRequest llsdRequest = new TRequest();
32 LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
33
34 TResponse response = m_method(llsdRequest);
35
36 return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) );
37
38 }
39 }
40}
diff --git a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj
index 4667d52..4b672ae 100644
--- a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj
+++ b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.csproj
@@ -123,6 +123,12 @@
123 <Compile Include="LLSDMapRequest.cs"> 123 <Compile Include="LLSDMapRequest.cs">
124 <SubType>Code</SubType> 124 <SubType>Code</SubType>
125 </Compile> 125 </Compile>
126 <Compile Include="LLSDMethod.cs">
127 <SubType>Code</SubType>
128 </Compile>
129 <Compile Include="LLSDStreamHandler.cs">
130 <SubType>Code</SubType>
131 </Compile>
126 <Compile Include="LLSDTest.cs"> 132 <Compile Include="LLSDTest.cs">
127 <SubType>Code</SubType> 133 <SubType>Code</SubType>
128 </Compile> 134 </Compile>
diff --git a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build
index a091b5c..1d552c2 100644
--- a/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build
+++ b/OpenSim/Region/Capabilities/OpenSim.Region.Capabilities.dll.build
@@ -20,6 +20,8 @@
20 <include name="LLSDMapLayer.cs" /> 20 <include name="LLSDMapLayer.cs" />
21 <include name="LLSDMapLayerResponse.cs" /> 21 <include name="LLSDMapLayerResponse.cs" />
22 <include name="LLSDMapRequest.cs" /> 22 <include name="LLSDMapRequest.cs" />
23 <include name="LLSDMethod.cs" />
24 <include name="LLSDStreamHandler.cs" />
23 <include name="LLSDTest.cs" /> 25 <include name="LLSDTest.cs" />
24 <include name="LLSDType.cs" /> 26 <include name="LLSDType.cs" />
25 <include name="LLSDUploadReply.cs" /> 27 <include name="LLSDUploadReply.cs" />
diff --git a/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
index f946482..d0ef2af 100644
--- a/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
+++ b/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
@@ -2,40 +2,9 @@ using System.Collections;
2using System.Text; 2using System.Text;
3using libsecondlife; 3using libsecondlife;
4using OpenSim.Region.Capabilities; 4using OpenSim.Region.Capabilities;
5using System.IO;
5 6
6namespace OpenSim.Framework.Servers 7namespace OpenSim.Framework.Servers
7{ 8{
8 public class LlsdMethodEntry<TResponse, TRequest> : ILlsdMethodHandler 9
9 where TRequest : new()
10 {
11 private LlsdMethod<TResponse, TRequest> m_method;
12
13
14 public LlsdMethodEntry( )
15 {
16
17 }
18
19 public LlsdMethodEntry(LlsdMethod<TResponse, TRequest> method)
20 {
21 m_method = method;
22 }
23
24 #region ILlsdMethodHandler Members
25
26 public string Handle(string body, string path)
27 {
28 Encoding _enc = Encoding.UTF8;
29 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes( body ));
30 TRequest request = new TRequest();
31
32 LLSDHelpers.DeserialiseLLSDMap(hash, request );
33
34 TResponse response = m_method(request);
35
36 return LLSDHelpers.SerialiseLLSDReply( response );
37 }
38
39 #endregion
40 }
41} 10}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index bc84c35..ad70df8 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -60,8 +60,6 @@ namespace SimpleApp
60 60
61 httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod ); 61 httpServer.AddXmlRPCHandler("login_to_simulator", communicationsManager.UserServices.XmlRpcLoginMethod );
62 62
63 RegisterLlsdHandler<LLSDMapLayerResponse, LLSDMapRequest>("/Caps/test/", LlsdMethodDemo);
64
65 httpServer.Start(); 63 httpServer.Start();
66 64
67 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit."); 65 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
@@ -74,27 +72,6 @@ namespace SimpleApp
74 72
75 } 73 }
76 74
77 private LLSDMapLayerResponse LlsdMethodDemo(LLSDMapRequest request)
78 {
79 return new LLSDMapLayerResponse();
80 }
81
82 ILlsdMethodHandler m_handler;
83
84 private void RegisterLlsdHandler<TResponse, TRequest>( string path, LlsdMethod<TResponse, TRequest> method )
85 where TRequest : new()
86 {
87 // path should be handler key, but for now just conceptually store it.
88 m_handler = new LlsdMethodEntry<TResponse, TRequest>( method );
89 }
90
91 private string ProcessLlsdMethod( string request,string path )
92 {
93 LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest> concreteHandler = new LlsdMethodEntry<LLSDMapLayerResponse, LLSDMapRequest>( LlsdMethodDemo );
94
95 return m_handler.Handle(request, path);
96 }
97
98 private bool AddNewSessionHandler(ulong regionHandle, Login loginData) 75 private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
99 { 76 {
100 m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last); 77 m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);