diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Capabilities/LLSDStreamHandler.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs new file mode 100644 index 0000000..7d99b6e --- /dev/null +++ b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs | |||
@@ -0,0 +1,42 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Framework.Servers; | ||
5 | using System.IO; | ||
6 | using System.Collections; | ||
7 | using libsecondlife; | ||
8 | |||
9 | namespace 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, false); | ||
26 | |||
27 | //string requestBody = streamReader.ReadToEnd(); | ||
28 | //streamReader.Close(); | ||
29 | |||
30 | Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request ); | ||
31 | TRequest llsdRequest = new TRequest(); | ||
32 | LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); | ||
33 | |||
34 | TResponse response = m_method(llsdRequest); | ||
35 | |||
36 | Encoding encoding = new UTF8Encoding(false); | ||
37 | |||
38 | return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) ); | ||
39 | |||
40 | } | ||
41 | } | ||
42 | } | ||