From 4e0a289a8dfc069201a856d2a67510c5b6b91ccf Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Nov 2010 14:13:27 +0000 Subject: [PATCH] Change FS Voice module to a shared module to avoid gratuitious server handler registrations. Add the missing bits to drive the local connector's HTTP requests. This makes standalones work. --- .../FreeSwitchVoice/FreeSwitchVoiceModule.cs | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 294d4f0615..9a17233cd5 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -58,7 +58,7 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FreeSwitchVoiceModule")] - public class FreeSwitchVoiceModule : INonSharedRegionModule, IVoiceModule + public class FreeSwitchVoiceModule : ISharedRegionModule, IVoiceModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -97,8 +97,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private readonly Dictionary m_UUIDName = new Dictionary(); private Dictionary m_ParcelAddress = new Dictionary(); - private Scene m_Scene; - private IConfig m_Config; private IFreeswitchService m_FreeswitchService; @@ -165,6 +163,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); + MainServer.Instance.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); + // RestStreamHandler h = new // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); @@ -214,15 +214,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } } + public void PostInitialise() + { + } + public void AddRegion(Scene scene) { - m_Scene = scene; - // We generate these like this: The region's external host name // as defined in Regions.ini is a good address to use. It's a // dotted quad (or should be!) and it can reach this host from // a client. The port is grabbed from the region's HTTP server. - m_openSimWellKnownHTTPAddress = m_Scene.RegionInfo.ExternalHostName; + m_openSimWellKnownHTTPAddress = scene.RegionInfo.ExternalHostName; m_freeSwitchServicePort = MainServer.Instance.Port; if (m_Enabled) @@ -790,6 +792,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { return true; } + + public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) + { + Hashtable response = new Hashtable(); + response["str_response_string"] = string.Empty; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["int_response_code"] = 500; + + Hashtable requestBody = ParseRequestBody((string) request["body"]); + + string section = (string) requestBody["section"]; + + if (section == "directory") + response = m_FreeswitchService.HandleDirectoryRequest(requestBody); + else if (section == "dialplan") + response = m_FreeswitchService.HandleDialplanRequest(requestBody); + else + m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); + + return response; + } } public class MonoCert : ICertificatePolicy