aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs')
-rw-r--r--OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs46
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
28using System; 28using System;
29using System.Collections;
30using System.Web;
31using System.Reflection;
29using Nini.Config; 32using Nini.Config;
30using OpenSim.Server.Base; 33using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
32using OpenSim.Framework.Servers.HttpServer; 35using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Handlers.Base; 36using OpenSim.Server.Handlers.Base;
37using log4net;
34 38
35namespace OpenSim.Server.Handlers.Freeswitch 39namespace 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}