diff options
author | Melanie | 2010-11-21 20:59:01 +0000 |
---|---|---|
committer | Melanie | 2010-11-21 21:29:11 +0000 |
commit | c0ccfeebe78dc1d0136f86e5f0e9562c4804cfa9 (patch) | |
tree | 84d5075069f51f3d7f0af9f46e9274a8b1531c44 /OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs | |
parent | Fix global region coordinates that are delivered by llRequestSimulatorData. (diff) | |
download | opensim-SC-c0ccfeebe78dc1d0136f86e5f0e9562c4804cfa9.zip opensim-SC-c0ccfeebe78dc1d0136f86e5f0e9562c4804cfa9.tar.gz opensim-SC-c0ccfeebe78dc1d0136f86e5f0e9562c4804cfa9.tar.bz2 opensim-SC-c0ccfeebe78dc1d0136f86e5f0e9562c4804cfa9.tar.xz |
Start implementing Freeswitch in ROBUST
Diffstat (limited to 'OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs b/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs index 07bafc8..150df45 100644 --- a/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs +++ b/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs | |||
@@ -26,18 +26,25 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Web; | ||
31 | using System.Reflection; | ||
29 | using Nini.Config; | 32 | using Nini.Config; |
30 | using OpenSim.Server.Base; | 33 | using OpenSim.Server.Base; |
31 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
32 | using OpenSim.Framework.Servers.HttpServer; | 35 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Server.Handlers.Base; | 36 | using OpenSim.Server.Handlers.Base; |
37 | using log4net; | ||
34 | 38 | ||
35 | namespace OpenSim.Server.Handlers.Freeswitch | 39 | namespace OpenSim.Server.Handlers.Freeswitch |
36 | { | 40 | { |
37 | public class FreeswitchServerConnector : ServiceConnector | 41 | public class FreeswitchServerConnector : ServiceConnector |
38 | { | 42 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
39 | private IFreeswitchService m_FreeswitchService; | 45 | private IFreeswitchService m_FreeswitchService; |
40 | private string m_ConfigName = "FreeswitchService"; | 46 | private string m_ConfigName = "FreeswitchService"; |
47 | protected readonly string m_freeSwitchAPIPrefix = "/fsapi"; | ||
41 | 48 | ||
42 | public FreeswitchServerConnector(IConfigSource config, IHttpServer server, string configName) : | 49 | public FreeswitchServerConnector(IConfigSource config, IHttpServer server, string configName) : |
43 | base(config, server, configName) | 50 | base(config, server, configName) |
@@ -59,7 +66,44 @@ namespace OpenSim.Server.Handlers.Freeswitch | |||
59 | m_FreeswitchService = | 66 | m_FreeswitchService = |
60 | ServerUtils.LoadPlugin<IFreeswitchService>(freeswitchService, args); | 67 | ServerUtils.LoadPlugin<IFreeswitchService>(freeswitchService, args); |
61 | 68 | ||
62 | server.AddStreamHandler(new FreeswitchServerGetHandler(m_FreeswitchService)); | 69 | server.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); |
70 | } | ||
71 | |||
72 | public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) | ||
73 | { | ||
74 | Hashtable response = new Hashtable(); | ||
75 | response["str_response_string"] = string.Empty; | ||
76 | |||
77 | Hashtable requestBody = ParseRequestBody((string) request["body"]); | ||
78 | |||
79 | string section = (string) requestBody["section"]; | ||
80 | |||
81 | if (section == "directory") | ||
82 | response = m_FreeswitchService.HandleDirectoryRequest(requestBody); | ||
83 | else if (section == "dialplan") | ||
84 | response = m_FreeswitchService.HandleDialplanRequest(requestBody); | ||
85 | else | ||
86 | m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); | ||
87 | |||
88 | return response; | ||
89 | } | ||
90 | |||
91 | private Hashtable ParseRequestBody(string body) | ||
92 | { | ||
93 | Hashtable bodyParams = new Hashtable(); | ||
94 | // split string | ||
95 | string [] nvps = body.Split(new Char [] {'&'}); | ||
96 | |||
97 | foreach (string s in nvps) | ||
98 | { | ||
99 | if (s.Trim() != "") | ||
100 | { | ||
101 | string [] nvp = s.Split(new Char [] {'='}); | ||
102 | bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1])); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | return bodyParams; | ||
63 | } | 107 | } |
64 | } | 108 | } |
65 | } | 109 | } |