aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Examples/SimpleApp/LlsdMethodEntry.cs
blob: f946482847283d83c3be390f688daf1713a8b2e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections;
using System.Text;
using libsecondlife;
using OpenSim.Region.Capabilities;

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 = 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
    }
}