From 180be7de07014aa33bc6066f12a0819b731c1c9d Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 10 Feb 2009 13:10:57 +0000 Subject: this is step 2 of 2 of the OpenSim.Region.Environment refactor. NOTHING has been deleted or moved off to forge at this point. what has happened is that OpenSim.Region.Environment.Modules has been split in two: - OpenSim.Region.CoreModules: all those modules that are either directly or indirectly referenced from other OpenSim packages, or that provide functionality that the OpenSim developer community considers core functionality: CoreModules/Agent/AssetTransaction CoreModules/Agent/Capabilities CoreModules/Agent/TextureDownload CoreModules/Agent/TextureSender CoreModules/Agent/TextureSender/Tests CoreModules/Agent/Xfer CoreModules/Avatar/AvatarFactory CoreModules/Avatar/Chat/ChatModule CoreModules/Avatar/Combat CoreModules/Avatar/Currency/SampleMoney CoreModules/Avatar/Dialog CoreModules/Avatar/Friends CoreModules/Avatar/Gestures CoreModules/Avatar/Groups CoreModules/Avatar/InstantMessage CoreModules/Avatar/Inventory CoreModules/Avatar/Inventory/Archiver CoreModules/Avatar/Inventory/Transfer CoreModules/Avatar/Lure CoreModules/Avatar/ObjectCaps CoreModules/Avatar/Profiles CoreModules/Communications/Local CoreModules/Communications/REST CoreModules/Framework/EventQueue CoreModules/Framework/InterfaceCommander CoreModules/Hypergrid CoreModules/InterGrid CoreModules/Scripting/DynamicTexture CoreModules/Scripting/EMailModules CoreModules/Scripting/HttpRequest CoreModules/Scripting/LoadImageURL CoreModules/Scripting/VectorRender CoreModules/Scripting/WorldComm CoreModules/Scripting/XMLRPC CoreModules/World/Archiver CoreModules/World/Archiver/Tests CoreModules/World/Estate CoreModules/World/Land CoreModules/World/Permissions CoreModules/World/Serialiser CoreModules/World/Sound CoreModules/World/Sun CoreModules/World/Terrain CoreModules/World/Terrain/DefaultEffects CoreModules/World/Terrain/DefaultEffects/bin CoreModules/World/Terrain/DefaultEffects/bin/Debug CoreModules/World/Terrain/Effects CoreModules/World/Terrain/FileLoaders CoreModules/World/Terrain/FloodBrushes CoreModules/World/Terrain/PaintBrushes CoreModules/World/Terrain/Tests CoreModules/World/Vegetation CoreModules/World/Wind CoreModules/World/WorldMap - OpenSim.Region.OptionalModules: all those modules that are not core modules: OptionalModules/Avatar/Chat/IRC-stuff OptionalModules/Avatar/Concierge OptionalModules/Avatar/Voice/AsterixVoice OptionalModules/Avatar/Voice/SIPVoice OptionalModules/ContentManagementSystem OptionalModules/Grid/Interregion OptionalModules/Python OptionalModules/SvnSerialiser OptionalModules/World/NPC OptionalModules/World/TreePopulator --- .../Voice/AsterixVoice/AsteriskVoiceModule.cs | 292 +++++++++++++++++++++ .../Avatar/Voice/SIPVoice/SIPVoiceModule.cs | 202 ++++++++++++++ 2 files changed, 494 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs create mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs new file mode 100644 index 0000000..c827214 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs @@ -0,0 +1,292 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Reflection; +using OpenMetaverse; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using Caps=OpenSim.Framework.Communications.Capabilities.Caps; + +namespace OpenSim.Region.OptionalModules.Avatar.Voice.AsterixVoice +{ + public class AsteriskVoiceModule : IRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; + + private string m_asterisk; + private string m_asterisk_password; + private string m_asterisk_salt; + private int m_asterisk_timeout; + private string m_confDomain; + private IConfig m_config; + private Scene m_scene; + private string m_sipDomain; + + #region IRegionModule Members + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_config = config.Configs["AsteriskVoice"]; + + if (null == m_config) + { + m_log.Info("[ASTERISKVOICE] no config found, plugin disabled"); + return; + } + + if (!m_config.GetBoolean("enabled", false)) + { + m_log.Info("[ASTERISKVOICE] plugin disabled by configuration"); + return; + } + m_log.Info("[ASTERISKVOICE] plugin enabled"); + + try + { + m_sipDomain = m_config.GetString("sip_domain", String.Empty); + m_log.InfoFormat("[ASTERISKVOICE] using SIP domain {0}", m_sipDomain); + + m_confDomain = m_config.GetString("conf_domain", String.Empty); + m_log.InfoFormat("[ASTERISKVOICE] using conf domain {0}", m_confDomain); + + m_asterisk = m_config.GetString("asterisk_frontend", String.Empty); + m_asterisk_password = m_config.GetString("asterisk_password", String.Empty); + m_asterisk_timeout = m_config.GetInt("asterisk_timeout", 3000); + m_asterisk_salt = m_config.GetString("asterisk_salt", "Wuffwuff"); + if (String.IsNullOrEmpty(m_asterisk)) throw new Exception("missing asterisk_frontend config parameter"); + if (String.IsNullOrEmpty(m_asterisk_password)) throw new Exception("missing asterisk_password config parameter"); + m_log.InfoFormat("[ASTERISKVOICE] using asterisk front end {0}", m_asterisk); + + scene.EventManager.OnRegisterCaps += OnRegisterCaps; + } + catch (Exception e) + { + m_log.ErrorFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.Message); + m_log.DebugFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.ToString()); + return; + } + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "AsteriskVoiceModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + #endregion + + public void OnRegisterCaps(UUID agentID, Caps caps) + { + m_log.DebugFormat("[ASTERISKVOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); + string capsBase = "/CAPS/" + caps.CapsObjectPath; + caps.RegisterHandler("ParcelVoiceInfoRequest", + new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ParcelVoiceInfoRequest(request, path, param, + agentID, caps); + })); + caps.RegisterHandler("ProvisionVoiceAccountRequest", + new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ProvisionVoiceAccountRequest(request, path, param, + agentID, caps); + })); + } + + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// + /// + /// + /// + /// + /// + public string ParcelVoiceInfoRequest(string request, string path, string param, + UUID agentID, Caps caps) + { + // we need to do: + // - send channel_uri: as "sip:regionID@m_sipDomain" + try + { + m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", + request, path, param); + + + // setup response to client + Hashtable creds = new Hashtable(); + creds["channel_uri"] = String.Format("sip:{0}@{1}", + m_scene.RegionInfo.RegionID, m_sipDomain); + + string regionName = m_scene.RegionInfo.RegionName; + ScenePresence avatar = m_scene.GetScenePresence(agentID); + if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); + LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + + LLSDParcelVoiceInfoResponse parcelVoiceInfo = + new LLSDParcelVoiceInfoResponse(regionName, land.LocalID, creds); + + string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); + + + // update region on asterisk-opensim frontend + Hashtable requestData = new Hashtable(); + requestData["admin_password"] = m_asterisk_password; + requestData["region"] = m_scene.RegionInfo.RegionID.ToString(); + if (!String.IsNullOrEmpty(m_confDomain)) + { + requestData["region"] += String.Format("@{0}", m_confDomain); + } + + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest updateAccountRequest = new XmlRpcRequest("region_update", SendParams); + XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); + Hashtable responseData = (Hashtable) updateAccountResponse.Value; + + if (!responseData.ContainsKey("success")) throw new Exception("region_update call failed"); + + bool success = Convert.ToBoolean((string) responseData["success"]); + if (!success) throw new Exception("region_update failed"); + + + m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: {0}", r); + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[ASTERISKVOICE][CAPS][PARCELVOICE]: {0}, retry later", e.Message); + m_log.DebugFormat("[ASTERISKVOICE][CAPS][PARCELVOICE]: {0} failed", e.ToString()); + + return "undef"; + } + } + + /// + /// Callback for a client request for Voice Account Details + /// + /// + /// + /// + /// + /// + /// + public string ProvisionVoiceAccountRequest(string request, string path, string param, + UUID agentID, Caps caps) + { + // we need to + // - get user data from UserProfileCacheService + // - generate nonce for user voice account password + // - issue XmlRpc request to asterisk opensim front end: + // + user: base 64 encoded user name (otherwise SL + // client is unhappy) + // + password: nonce + // - the XmlRpc call to asteris-opensim was successful: + // send account details back to client + try + { + m_log.DebugFormat("[ASTERISKVOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", + request, path, param); + + // get user data & prepare voice account response + string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); + voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); + + CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); + if (null == userInfo) throw new Exception("cannot get user details"); + + // we generate a nonce everytime + string voicePassword = "$1$" + Util.Md5Hash(DateTime.UtcNow.ToLongTimeString() + m_asterisk_salt); + LLSDVoiceAccountResponse voiceAccountResponse = + new LLSDVoiceAccountResponse(voiceUser, voicePassword); + string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); + m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); + + + // update user account on asterisk frontend + Hashtable requestData = new Hashtable(); + requestData["admin_password"] = m_asterisk_password; + requestData["username"] = voiceUser; + if (!String.IsNullOrEmpty(m_sipDomain)) + { + requestData["username"] += String.Format("@{0}", m_sipDomain); + } + requestData["password"] = voicePassword; + + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest updateAccountRequest = new XmlRpcRequest("account_update", SendParams); + XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); + Hashtable responseData = (Hashtable) updateAccountResponse.Value; + + if (!responseData.ContainsKey("success")) throw new Exception("account_update call failed"); + + bool success = Convert.ToBoolean((string) responseData["success"]); + if (!success) throw new Exception("account_update failed"); + + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[ASTERISKVOICE][CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); + m_log.DebugFormat("[ASTERISKVOICE][CAPS][PROVISIONVOICE]: {0} failed", e.ToString()); + + return "undef"; + } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs new file mode 100644 index 0000000..3e8a433 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs @@ -0,0 +1,202 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Reflection; +using OpenMetaverse; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using Caps=OpenSim.Framework.Communications.Capabilities.Caps; + +namespace OpenSim.Region.OptionalModules.Avatar.Voice.SIPVoice +{ + public class SIPVoiceModule : IRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; + private IConfig m_config; + private Scene m_scene; + private string m_sipDomain; + + #region IRegionModule Members + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_config = config.Configs["Voice"]; + + if (null == m_config || !m_config.GetBoolean("enabled", false)) + { + m_log.Info("[VOICE] plugin disabled"); + return; + } + m_log.Info("[VOICE] plugin enabled"); + + m_sipDomain = m_config.GetString("sip_domain", String.Empty); + if (String.IsNullOrEmpty(m_sipDomain)) + { + m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); + m_log.Info("[VOICE] plugin disabled"); + return; + } + m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); + + scene.EventManager.OnRegisterCaps += OnRegisterCaps; + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "VoiceModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + #endregion + + public void OnRegisterCaps(UUID agentID, Caps caps) + { + m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); + string capsBase = "/CAPS/" + caps.CapsObjectPath; + caps.RegisterHandler("ParcelVoiceInfoRequest", + new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ParcelVoiceInfoRequest(request, path, param, + agentID, caps); + })); + caps.RegisterHandler("ProvisionVoiceAccountRequest", + new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ProvisionVoiceAccountRequest(request, path, param, + agentID, caps); + })); + } + + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// + /// + /// + /// + /// + /// + public string ParcelVoiceInfoRequest(string request, string path, string param, + UUID agentID, Caps caps) + { + try + { + m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); + + // FIXME: get the creds from region file or from config + Hashtable creds = new Hashtable(); + + creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain); + + string regionName = m_scene.RegionInfo.RegionName; + ScenePresence avatar = m_scene.GetScenePresence(agentID); + if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); + LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + + LLSDParcelVoiceInfoResponse parcelVoiceInfo = + new LLSDParcelVoiceInfoResponse(regionName, land.LocalID, creds); + + string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); + m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); + + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); + } + + return null; + } + + /// + /// Callback for a client request for Voice Account Details + /// + /// + /// + /// + /// + /// + /// + public string ProvisionVoiceAccountRequest(string request, string path, string param, + UUID agentID, Caps caps) + { + try + { + m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", + request, path, param); + + string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); + voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); + + CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); + if (null == userInfo) throw new Exception("cannot get user details"); + + LLSDVoiceAccountResponse voiceAccountResponse = + new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash); + string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); + m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); + } + + return null; + } + } +} -- cgit v1.1 From 1caf1c5d96dfa6863f524f57247befc9359e7259 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 19 Mar 2009 08:42:59 +0000 Subject: adding missing ChatSessionRequest voice capability for direct AV-AV calls. --- .../Avatar/Voice/SIPVoice/SIPVoiceModule.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs index 3e8a433..d00a256 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs @@ -48,6 +48,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.SIPVoice private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; + private static readonly string m_chatSessionRequestPath = "0009/"; private IConfig m_config; private Scene m_scene; private string m_sipDomain; @@ -118,6 +119,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.SIPVoice return ProvisionVoiceAccountRequest(request, path, param, agentID, caps); })); + caps.RegisterHandler("ChatSessionRequest", + new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ChatSessionRequest(request, path, param, + agentID, caps); + })); + } /// @@ -198,5 +208,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.SIPVoice return null; } + + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// current scene object of the client + /// + /// + /// + /// + /// + /// + public string ChatSessionRequest(string request, string path, string param, + UUID agentID, Caps caps) + { + ScenePresence avatar = m_scene.GetScenePresence(agentID); + string avatarName = avatar.Name; + + m_log.DebugFormat("[CAPS][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", + avatarName, request, path, param); + return "true"; + } + } } -- cgit v1.1 From 7f30be17d0ee841961262ee9e9b8fab27ccf6d83 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 17 Apr 2009 20:00:30 +0000 Subject: experimental freeswitch code, imported from Rob Smart's tree --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 88 ++++ .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 335 ++++++++++++ .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 571 +++++++++++++++++++++ 3 files changed, 994 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs create mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs create mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs new file mode 100644 index 0000000..2a2b4a3 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using log4net; +using System.Reflection; +using System.Collections; + +namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice +{ + public class FreeSwitchDialplan + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + + public Hashtable HandleDialplanRequest(Hashtable request) + { + m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString()); + + Hashtable response = new Hashtable(); + + foreach(DictionaryEntry item in request) + { + m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); + } + + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"]=200; + response["str_response_string"] = @" + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
"; + + return response; + } + } + +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs new file mode 100644 index 0000000..9959d11 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -0,0 +1,335 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using log4net; +using System; +using System.Reflection; +using System.Text; +using System.Collections; + +namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice +{ + public class FreeSwitchDirectory + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public Hashtable HandleDirectoryRequest(Hashtable request) + { + m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); + + Hashtable response = new Hashtable(); + + // information in the request we might be interested in + + // Request 1 sip_auth for users account + + //Event-Calling-Function=sofia_reg_parse_auth + //Event-Calling-Line-Number=1494 + //action=sip_auth + //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41) + //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) + //sip_auth_realm=9.20.151.43 + //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) + //sip_contact_host=192.168.0.3 // this shouldnt really be a local IP, investigate STUN servers + //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D + //sip_to_host=9.20.151.43 + //sip_auth_method=REGISTER + //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D + //domain=9.20.151.43 + //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup + + foreach(DictionaryEntry item in request) + { + m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); + } + + string eventCallingFunction = (string) request["Event-Calling-Function"]; + + + if(eventCallingFunction=="sofia_reg_parse_auth") + { + string sipAuthMethod = (string)request["sip_auth_method"]; + + if(sipAuthMethod=="REGISTER") + { + response = HandleRegister(request); + } + else if(sipAuthMethod=="INVITE") + { + response = HandleInvite(request); + } + else + { + m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); + response["int_response_code"]=404; + } + } + else if(eventCallingFunction=="switch_xml_locate_user") + { + response = HandleLocateUser(request); + } + else if(eventCallingFunction=="user_data_function") // gets called when an avatar to avatar call is made + { + response = HandleLocateUser(request); + } + else if(eventCallingFunction=="user_outgoing_channel") + { + response = HandleRegister(request); + } + else if(eventCallingFunction=="config_sofia") // happens once on freeswitch startup + { + response = HandleConfigSofia(request); + } + else if(eventCallingFunction=="switch_load_network_lists") + { + //response = HandleLoadNetworkLists(request); + response["int_response_code"]=404; + response["keepalive"] = false; + } + else + { + m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); + response["int_response_code"]=404; + response["keepalive"] = false; + } + + + + return response; + } + + private Hashtable HandleRegister(Hashtable request) + { + m_log.Info("[FreeSwitchDirectory] HandleRegister called"); + + // TODO the password we return needs to match that sent in the request, this is hard coded for now + string password = "1234"; + string domain = (string) request["domain"]; + string user = (string) request["user"]; + + Hashtable response = new Hashtable(); + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"]=200; + response["str_response_string"] = String.Format( + "\r\n" + + "\r\n" + + "
\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + ""+ + "\r\n" + + "\r\n" + + "\r\n" + + "
\r\n" + + "
\r\n" + , domain , user, password); + + return response; + + } + + private Hashtable HandleInvite(Hashtable request) + { + m_log.Info("[FreeSwitchDirectory] HandleInvite called"); + + // TODO the password we return needs to match that sent in the request, this is hard coded for now + string password = "1234"; + string domain = (string) request["domain"]; + string user = (string) request["user"]; + string sipRequestUser = (string) request["sip_request_user"]; + + Hashtable response = new Hashtable(); + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"]=200; + response["str_response_string"] = String.Format( + "\r\n" + + "\r\n" + + "
\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + ""+ + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + ""+ + "\r\n" + + "\r\n" + + "\r\n" + + "
\r\n" + + "
\r\n" + , domain , user, password,sipRequestUser); + + return response; + } + + + private Hashtable HandleLocateUser(Hashtable request) + { + m_log.Info("[FreeSwitchDirectory] HandleLocateUser called"); + + // TODO the password we return needs to match that sent in the request, this is hard coded for now + string domain = (string) request["domain"]; + string user = (string) request["user"]; + + Hashtable response = new Hashtable(); + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"]=200; + response["str_response_string"] = String.Format( + "\r\n" + + "\r\n" + + "
\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n"+ + "\r\n"+ + ""+ + "\r\n"+ + "\r\n" + + "\r\n" + + "
\r\n" + + "
\r\n" + , domain , user); + + + + return response; + } + + private Hashtable HandleConfigSofia(Hashtable request) + { + m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called"); + + // TODO the password we return needs to match that sent in the request, this is hard coded for now + string domain = (string) request["domain"]; + + Hashtable response = new Hashtable(); + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"]=200; + response["str_response_string"] = String.Format( + "\r\n" + + "\r\n" + + "
\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + ""+ + "\r\n" + + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n" + + "
\r\n" + + "
\r\n" + , domain); + + + return response; + } + + private Hashtable HandleLoadNetworkLists(Hashtable request) + { + m_log.Info("[FreeSwitchDirectory] HandleLoadNetworkLists called"); + + // TODO the password we return needs to match that sent in the request, this is hard coded for now + string domain = (string) request["domain"]; + + Hashtable response = new Hashtable(); + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"]=200; + response["str_response_string"] = String.Format( + "\r\n" + + "\r\n" + + "
\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n" + + "
\r\n" + + "
\r\n" + , domain); + + + return response; + } + + } + +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs new file mode 100644 index 0000000..a8f9de6 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -0,0 +1,571 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Net; +using System.Web; +using System.Text; +using System.Xml; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using OpenMetaverse; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using Caps = OpenSim.Framework.Communications.Capabilities.Caps; + +namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice +{ + public class FreeSwitchVoiceModule : IRegionModule + { + + // Infrastructure + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly bool DUMP = true; + + // Capability string prefixes + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; + private static readonly string m_chatSessionRequestPath = "0009/"; + + // Control info + private static bool m_WOF = true; + private static bool m_pluginEnabled = false; + + // FreeSwitch server is going to contact us and ask us all + // sorts of things. + private static string m_freeSwitchServerUser; + private static string m_freeSwitchServerPass; + + // SLVoice client will do a GET on this prefix + private static string m_freeSwitchAPIPrefix; + + // We need to return some information to SLVoice + // figured those out via curl + // http://vd1.vivox.com/api2/viv_get_prelogin.php + // + // need to figure out whether we do need to return ALL of + // these... + private static string m_freeSwitchRealm; + private static string m_freeSwitchSIPProxy; + private static bool m_freeSwitchAttemptUseSTUN; + private static string m_freeSwitchSTUNServer; + private static string m_freeSwitchEchoServer; + private static int m_freeSwitchEchoPort; + private static string m_freeSwitchDefaultWellKnownIP; + private static int m_freeSwitchDefaultTimeout; + private static int m_freeSwitchSubscribeRetry; + private static string m_freeSwitchUrlResetPassword; + private static IPEndPoint m_FreeSwitchServiceIP; + + private FreeSwitchDirectory m_FreeSwitchDirectory; + private FreeSwitchDialplan m_FreeSwitchDialplan; + + private IConfig m_config; + + public void Initialise(Scene scene, IConfigSource config) + { + + m_config = config.Configs["FreeSwitchVoice"]; + + if (null == m_config) + { + m_log.Info("[FreeSwitchVoice] no config found, plugin disabled"); + return; + } + + if (!m_config.GetBoolean("enabled", false)) + { + m_log.Info("[FreeSwitchVoice] plugin disabled by configuration"); + return; + } + + // This is only done the FIRST time this method is invoked. + if (m_WOF) + { + m_pluginEnabled = true; + m_WOF = false; + + try + { + m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); + m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); + m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); + + // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) + + string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); + int servicePort = m_config.GetInt("freeswitch_service_port", 80); + IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); + m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); + + m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); + m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); + m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); + m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); + m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); + m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); + m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); + m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); + m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); + m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); + + + + + if (String.IsNullOrEmpty(m_freeSwitchServerUser) || + String.IsNullOrEmpty(m_freeSwitchServerPass) || + String.IsNullOrEmpty(m_freeSwitchRealm) || + String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) + { + m_log.Error("[FreeSwitchVoice] plugin mis-configured"); + m_log.Info("[FreeSwitchVoice] plugin disabled: incomplete configuration"); + return; + } + + // set up http request handlers for + // - prelogin: viv_get_prelogin.php + // - signin: viv_signin.php + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceGetPreloginHTTPHandler); + + // RestStreamHandler h = new RestStreamHandler("GET", String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); + // scene.CommsManager.HttpServer.AddStreamHandler(h); + + + + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceSigninHTTPHandler); + + // set up http request handlers to provide + // on-demand FreeSwitch configuration to + // FreeSwitch's mod_curl_xml + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), + FreeSwitchConfigHTTPHandler); + + m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); + + m_FreeSwitchDirectory = new FreeSwitchDirectory(); + m_FreeSwitchDialplan = new FreeSwitchDialplan(); + + m_pluginEnabled = true; + m_WOF = false; + + m_log.Info("[FreeSwitchVoice] plugin enabled"); + } + catch (Exception e) + { + m_log.ErrorFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); + m_log.DebugFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString()); + return; + } + } + + if (m_pluginEnabled) + { + // we need to capture scene in an anonymous method + // here as we need it later in the callbacks + scene.EventManager.OnRegisterCaps += delegate(UUID agentID, Caps caps) + { + OnRegisterCaps(scene, agentID, caps); + }; + + + + } + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "FreeSwitchVoiceModule"; } + } + + public bool IsSharedModule + { + get { return true; } + } + + + // + // OnRegisterCaps is invoked via the scene.EventManager + // everytime OpenSim hands out capabilities to a client + // (login, region crossing). We contribute two capabilities to + // the set of capabilities handed back to the client: + // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. + // + // ProvisionVoiceAccountRequest allows the client to obtain + // the voice account credentials for the avatar it is + // controlling (e.g., user name, password, etc). + // + // ParcelVoiceInfoRequest is invoked whenever the client + // changes from one region or parcel to another. + // + // Note that OnRegisterCaps is called here via a closure + // delegate containing the scene of the respective region (see + // Initialise()). + // + public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps) + { + m_log.DebugFormat("[FreeSwitchVoice] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); + + string capsBase = "/CAPS/" + caps.CapsObjectPath; + caps.RegisterHandler("ProvisionVoiceAccountRequest", + new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ProvisionVoiceAccountRequest(scene, request, path, param, + agentID, caps); + })); + caps.RegisterHandler("ParcelVoiceInfoRequest", + new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ParcelVoiceInfoRequest(scene, request, path, param, + agentID, caps); + })); + caps.RegisterHandler("ChatSessionRequest", + new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ChatSessionRequest(scene, request, path, param, + agentID, caps); + })); + } + + /// + /// Callback for a client request for Voice Account Details + /// + /// current scene object of the client + /// + /// + /// + /// + /// + /// + public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, + UUID agentID, Caps caps) + { + ScenePresence avatar = scene.GetScenePresence(agentID); + string avatarName = avatar.Name; + + try + { + m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", + request, path, param); + + //XmlElement resp; + string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); + string password = "1234";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); + + // XXX: we need to cache the voice credentials, as + // FreeSwitch is later going to come and ask us for + // those + + agentname = agentname.Replace('+', '-').Replace('/', '_'); + + // LLSDVoiceAccountResponse voiceAccountResponse = + // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); + LLSDVoiceAccountResponse voiceAccountResponse = + new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, + String.Format("http://{0}/{1}/", m_FreeSwitchServiceIP, + m_freeSwitchAPIPrefix)); + + string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); + + m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); + + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}, retry later", avatarName, e.Message); + m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1} failed", avatarName, e.ToString()); + + return "undef"; + } + } + + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// current scene object of the client + /// + /// + /// + /// + /// + /// + public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, + UUID agentID, Caps caps) + { + ScenePresence avatar = scene.GetScenePresence(agentID); + string avatarName = avatar.Name; + + // - check whether we have a region channel in our cache + // - if not: + // create it and cache it + // - send it to the client + // - send channel_uri: as "sip:regionID@m_sipDomain" + try + { + LLSDParcelVoiceInfoResponse parcelVoiceInfo; + string channelUri; + + if (null == scene.LandChannel) + throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", + scene.RegionInfo.RegionName, avatarName)); + + + + // get channel_uri: check first whether estate + // settings allow voice, then whether parcel allows + // voice, if all do retrieve or obtain the parcel + // voice channel + LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + + m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", + scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); + + // TODO: EstateSettings don't seem to get propagated... + // if (!scene.RegionInfo.EstateSettings.AllowVoice) + // { + // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", + // scene.RegionInfo.RegionName); + // channel_uri = String.Empty; + // } + // else + + if ((land.Flags & (uint)Parcel.ParcelFlags.AllowVoiceChat) == 0) + { + m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", + scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); + channelUri = String.Empty; + } + else + { + channelUri = ChannelUri(scene, land); + } + + // fill in our response to the client + Hashtable creds = new Hashtable(); + creds["channel_uri"] = channelUri; + + parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); + string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); + + m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", + scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", + scene.RegionInfo.RegionName, avatarName, e.Message); + m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", + scene.RegionInfo.RegionName, avatarName, e.ToString()); + + return "undef"; + } + } + + + /// + /// Callback for a client request for ChatSessionRequest + /// + /// current scene object of the client + /// + /// + /// + /// + /// + /// + public string ChatSessionRequest(Scene scene, string request, string path, string param, + UUID agentID, Caps caps) + { + ScenePresence avatar = scene.GetScenePresence(agentID); + string avatarName = avatar.Name; + + m_log.DebugFormat("[FreeSwitchVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", + avatarName, request, path, param); + return "true"; + } + + + public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) + { + m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called"); + + Hashtable response = new Hashtable(); + response["content_type"] = "text/xml"; + response["keepalive"] = false; + + response["str_response_string"] = String.Format( + "\r\n" + + "\r\n"+ + "{0}\r\n" + + "{1}\r\n"+ + "{2}\r\n"+ + "{3}\r\n"+ + "{4}\r\n"+ + "{5}\r\n"+ + "{6}\r\n"+ + "{7}\r\n"+ + "{8}\r\n"+ + "\r\n"+ + "false\r\n"+ + "" + , + m_freeSwitchRealm,m_freeSwitchSIPProxy,m_freeSwitchAttemptUseSTUN, + m_freeSwitchSTUNServer,m_freeSwitchEchoServer,m_freeSwitchEchoPort, + m_freeSwitchDefaultWellKnownIP,m_freeSwitchDefaultTimeout,m_freeSwitchUrlResetPassword,""); + + response["int_response_code"] = 200; + + m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); + return response; + } + + public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) + { + m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); + + Hashtable response = new Hashtable(); + response["str_response_string"] = @" + + OK + + 200 + auth successful + + + "; + response["int_response_code"] = 200; + return response; + } + + + public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) + { + m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}",request.ToString()); + + Hashtable response = new Hashtable(); + + // all the params come as NVPs in the request body + Hashtable requestBody = parseRequestBody((string) request["body"]); + + // is this a dialplan or directory request + string section = (string) requestBody["section"]; + + if(section=="directory") + response = m_FreeSwitchDirectory.HandleDirectoryRequest(requestBody); + else if (section=="dialplan") + response = m_FreeSwitchDialplan.HandleDialplanRequest(requestBody); + + // XXX: re-generate dialplan: + // - conf == region UUID + // - conf number = region port + // -> TODO Initialise(): keep track of regions via events + // re-generate accounts for all avatars + // -> TODO Initialise(): keep track of avatars via events + m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",response["str_response_string"]); + return response; + } + + public Hashtable parseRequestBody(string body) + { + Hashtable bodyParams = new Hashtable(); + // split string + string [] nvps = body.Split(new Char [] {'&'}); + + foreach (string s in nvps) { + + if (s.Trim() != "") + { + string [] nvp = s.Split(new Char [] {'='}); + bodyParams.Add(HttpUtility.UrlDecode(nvp[0]),HttpUtility.UrlDecode(nvp[1])); + } + } + + return bodyParams; + + } + + private string ChannelUri(Scene scene, LandData land) + { + + string channelUri = null; + + string landUUID; + string landName; + + // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same + // as the directory ID. Otherwise, it reflects the parcel's ID. + + if (land.LocalID != 1 && (land.Flags & (uint)Parcel.ParcelFlags.UseEstateVoiceChan) == 0) + { + landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); + landUUID = land.GlobalID.ToString(); + m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", + landName, land.LocalID, landUUID); + } + else + { + landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); + landUUID = scene.RegionInfo.RegionID.ToString(); + m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", + landName, land.LocalID, landUUID); + } + System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); + channelUri = String.Format("sip:confctl-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); + + //channelUri="sip:confctl-3001@9.20.151.43"; + //channelUri="sip:opensimconf-3001@9.20.151.43"; + + return channelUri; + } + } +} -- cgit v1.1 From 4a8313f14c0aeffc87d37bd1f6c633a61c0a0fca Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 21 Apr 2009 16:06:16 +0000 Subject: culling AsteriskVoiceModule and SIPVoiceModule, now that we have working FreeSwitchVoiceModule and soon will have a fully working VivoxVoiceModule. --- .../Voice/AsterixVoice/AsteriskVoiceModule.cs | 292 --------------------- .../Avatar/Voice/SIPVoice/SIPVoiceModule.cs | 234 ----------------- 2 files changed, 526 deletions(-) delete mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs delete mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs deleted file mode 100644 index c827214..0000000 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Reflection; -using OpenMetaverse; -using log4net; -using Nini.Config; -using Nwc.XmlRpc; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using Caps=OpenSim.Framework.Communications.Capabilities.Caps; - -namespace OpenSim.Region.OptionalModules.Avatar.Voice.AsterixVoice -{ - public class AsteriskVoiceModule : IRegionModule - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; - private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; - - private string m_asterisk; - private string m_asterisk_password; - private string m_asterisk_salt; - private int m_asterisk_timeout; - private string m_confDomain; - private IConfig m_config; - private Scene m_scene; - private string m_sipDomain; - - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource config) - { - m_scene = scene; - m_config = config.Configs["AsteriskVoice"]; - - if (null == m_config) - { - m_log.Info("[ASTERISKVOICE] no config found, plugin disabled"); - return; - } - - if (!m_config.GetBoolean("enabled", false)) - { - m_log.Info("[ASTERISKVOICE] plugin disabled by configuration"); - return; - } - m_log.Info("[ASTERISKVOICE] plugin enabled"); - - try - { - m_sipDomain = m_config.GetString("sip_domain", String.Empty); - m_log.InfoFormat("[ASTERISKVOICE] using SIP domain {0}", m_sipDomain); - - m_confDomain = m_config.GetString("conf_domain", String.Empty); - m_log.InfoFormat("[ASTERISKVOICE] using conf domain {0}", m_confDomain); - - m_asterisk = m_config.GetString("asterisk_frontend", String.Empty); - m_asterisk_password = m_config.GetString("asterisk_password", String.Empty); - m_asterisk_timeout = m_config.GetInt("asterisk_timeout", 3000); - m_asterisk_salt = m_config.GetString("asterisk_salt", "Wuffwuff"); - if (String.IsNullOrEmpty(m_asterisk)) throw new Exception("missing asterisk_frontend config parameter"); - if (String.IsNullOrEmpty(m_asterisk_password)) throw new Exception("missing asterisk_password config parameter"); - m_log.InfoFormat("[ASTERISKVOICE] using asterisk front end {0}", m_asterisk); - - scene.EventManager.OnRegisterCaps += OnRegisterCaps; - } - catch (Exception e) - { - m_log.ErrorFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.Message); - m_log.DebugFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.ToString()); - return; - } - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "AsteriskVoiceModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - #endregion - - public void OnRegisterCaps(UUID agentID, Caps caps) - { - m_log.DebugFormat("[ASTERISKVOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); - string capsBase = "/CAPS/" + caps.CapsObjectPath; - caps.RegisterHandler("ParcelVoiceInfoRequest", - new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, - delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - return ParcelVoiceInfoRequest(request, path, param, - agentID, caps); - })); - caps.RegisterHandler("ProvisionVoiceAccountRequest", - new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, - delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - return ProvisionVoiceAccountRequest(request, path, param, - agentID, caps); - })); - } - - /// - /// Callback for a client request for ParcelVoiceInfo - /// - /// - /// - /// - /// - /// - /// - public string ParcelVoiceInfoRequest(string request, string path, string param, - UUID agentID, Caps caps) - { - // we need to do: - // - send channel_uri: as "sip:regionID@m_sipDomain" - try - { - m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", - request, path, param); - - - // setup response to client - Hashtable creds = new Hashtable(); - creds["channel_uri"] = String.Format("sip:{0}@{1}", - m_scene.RegionInfo.RegionID, m_sipDomain); - - string regionName = m_scene.RegionInfo.RegionName; - ScenePresence avatar = m_scene.GetScenePresence(agentID); - if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); - LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); - - LLSDParcelVoiceInfoResponse parcelVoiceInfo = - new LLSDParcelVoiceInfoResponse(regionName, land.LocalID, creds); - - string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); - - - // update region on asterisk-opensim frontend - Hashtable requestData = new Hashtable(); - requestData["admin_password"] = m_asterisk_password; - requestData["region"] = m_scene.RegionInfo.RegionID.ToString(); - if (!String.IsNullOrEmpty(m_confDomain)) - { - requestData["region"] += String.Format("@{0}", m_confDomain); - } - - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest updateAccountRequest = new XmlRpcRequest("region_update", SendParams); - XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); - Hashtable responseData = (Hashtable) updateAccountResponse.Value; - - if (!responseData.ContainsKey("success")) throw new Exception("region_update call failed"); - - bool success = Convert.ToBoolean((string) responseData["success"]); - if (!success) throw new Exception("region_update failed"); - - - m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: {0}", r); - return r; - } - catch (Exception e) - { - m_log.ErrorFormat("[ASTERISKVOICE][CAPS][PARCELVOICE]: {0}, retry later", e.Message); - m_log.DebugFormat("[ASTERISKVOICE][CAPS][PARCELVOICE]: {0} failed", e.ToString()); - - return "undef"; - } - } - - /// - /// Callback for a client request for Voice Account Details - /// - /// - /// - /// - /// - /// - /// - public string ProvisionVoiceAccountRequest(string request, string path, string param, - UUID agentID, Caps caps) - { - // we need to - // - get user data from UserProfileCacheService - // - generate nonce for user voice account password - // - issue XmlRpc request to asterisk opensim front end: - // + user: base 64 encoded user name (otherwise SL - // client is unhappy) - // + password: nonce - // - the XmlRpc call to asteris-opensim was successful: - // send account details back to client - try - { - m_log.DebugFormat("[ASTERISKVOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", - request, path, param); - - // get user data & prepare voice account response - string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); - voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); - - CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); - if (null == userInfo) throw new Exception("cannot get user details"); - - // we generate a nonce everytime - string voicePassword = "$1$" + Util.Md5Hash(DateTime.UtcNow.ToLongTimeString() + m_asterisk_salt); - LLSDVoiceAccountResponse voiceAccountResponse = - new LLSDVoiceAccountResponse(voiceUser, voicePassword); - string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); - m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); - - - // update user account on asterisk frontend - Hashtable requestData = new Hashtable(); - requestData["admin_password"] = m_asterisk_password; - requestData["username"] = voiceUser; - if (!String.IsNullOrEmpty(m_sipDomain)) - { - requestData["username"] += String.Format("@{0}", m_sipDomain); - } - requestData["password"] = voicePassword; - - ArrayList SendParams = new ArrayList(); - SendParams.Add(requestData); - XmlRpcRequest updateAccountRequest = new XmlRpcRequest("account_update", SendParams); - XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); - Hashtable responseData = (Hashtable) updateAccountResponse.Value; - - if (!responseData.ContainsKey("success")) throw new Exception("account_update call failed"); - - bool success = Convert.ToBoolean((string) responseData["success"]); - if (!success) throw new Exception("account_update failed"); - - return r; - } - catch (Exception e) - { - m_log.ErrorFormat("[ASTERISKVOICE][CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); - m_log.DebugFormat("[ASTERISKVOICE][CAPS][PROVISIONVOICE]: {0} failed", e.ToString()); - - return "undef"; - } - } - } -} diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs deleted file mode 100644 index d00a256..0000000 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Reflection; -using OpenMetaverse; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; -using OpenSim.Framework.Servers; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using Caps=OpenSim.Framework.Communications.Capabilities.Caps; - -namespace OpenSim.Region.OptionalModules.Avatar.Voice.SIPVoice -{ - public class SIPVoiceModule : IRegionModule - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; - private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; - private static readonly string m_chatSessionRequestPath = "0009/"; - private IConfig m_config; - private Scene m_scene; - private string m_sipDomain; - - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource config) - { - m_scene = scene; - m_config = config.Configs["Voice"]; - - if (null == m_config || !m_config.GetBoolean("enabled", false)) - { - m_log.Info("[VOICE] plugin disabled"); - return; - } - m_log.Info("[VOICE] plugin enabled"); - - m_sipDomain = m_config.GetString("sip_domain", String.Empty); - if (String.IsNullOrEmpty(m_sipDomain)) - { - m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); - m_log.Info("[VOICE] plugin disabled"); - return; - } - m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); - - scene.EventManager.OnRegisterCaps += OnRegisterCaps; - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "VoiceModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - #endregion - - public void OnRegisterCaps(UUID agentID, Caps caps) - { - m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); - string capsBase = "/CAPS/" + caps.CapsObjectPath; - caps.RegisterHandler("ParcelVoiceInfoRequest", - new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, - delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - return ParcelVoiceInfoRequest(request, path, param, - agentID, caps); - })); - caps.RegisterHandler("ProvisionVoiceAccountRequest", - new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, - delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - return ProvisionVoiceAccountRequest(request, path, param, - agentID, caps); - })); - caps.RegisterHandler("ChatSessionRequest", - new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, - delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) - { - return ChatSessionRequest(request, path, param, - agentID, caps); - })); - - } - - /// - /// Callback for a client request for ParcelVoiceInfo - /// - /// - /// - /// - /// - /// - /// - public string ParcelVoiceInfoRequest(string request, string path, string param, - UUID agentID, Caps caps) - { - try - { - m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); - - // FIXME: get the creds from region file or from config - Hashtable creds = new Hashtable(); - - creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain); - - string regionName = m_scene.RegionInfo.RegionName; - ScenePresence avatar = m_scene.GetScenePresence(agentID); - if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); - LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); - - LLSDParcelVoiceInfoResponse parcelVoiceInfo = - new LLSDParcelVoiceInfoResponse(regionName, land.LocalID, creds); - - string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); - m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); - - return r; - } - catch (Exception e) - { - m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); - } - - return null; - } - - /// - /// Callback for a client request for Voice Account Details - /// - /// - /// - /// - /// - /// - /// - public string ProvisionVoiceAccountRequest(string request, string path, string param, - UUID agentID, Caps caps) - { - try - { - m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", - request, path, param); - - string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); - voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); - - CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); - if (null == userInfo) throw new Exception("cannot get user details"); - - LLSDVoiceAccountResponse voiceAccountResponse = - new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash); - string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); - m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); - return r; - } - catch (Exception e) - { - m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); - } - - return null; - } - - /// - /// Callback for a client request for ParcelVoiceInfo - /// - /// current scene object of the client - /// - /// - /// - /// - /// - /// - public string ChatSessionRequest(string request, string path, string param, - UUID agentID, Caps caps) - { - ScenePresence avatar = m_scene.GetScenePresence(agentID); - string avatarName = avatar.Name; - - m_log.DebugFormat("[CAPS][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", - avatarName, request, path, param); - return "true"; - } - - } -} -- cgit v1.1 From 6aa5d3904d71c4be21e5991d9ba82dff3c1cf51f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 22 Apr 2009 00:48:56 +0000 Subject: Add copyright headers. Formatting cleanup. --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 60 ++++++++-------- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 84 +++++++++++----------- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 2 +- 3 files changed, 73 insertions(+), 73 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index 2a2b4a3..d8fce67 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -43,7 +43,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable response = new Hashtable(); - foreach(DictionaryEntry item in request) + foreach (DictionaryEntry item in request) { m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); } @@ -52,37 +52,37 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["keepalive"] = false; response["int_response_code"]=200; response["str_response_string"] = @" - -
- - - - - - - - - - - - - - - - - - - - - - - - -
-
"; + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
"; return response; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 9959d11..4113976 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice //domain=9.20.151.43 //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup - foreach(DictionaryEntry item in request) + foreach (DictionaryEntry item in request) { m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); } @@ -71,41 +71,41 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string eventCallingFunction = (string) request["Event-Calling-Function"]; - if(eventCallingFunction=="sofia_reg_parse_auth") + if (eventCallingFunction=="sofia_reg_parse_auth") { string sipAuthMethod = (string)request["sip_auth_method"]; - - if(sipAuthMethod=="REGISTER") - { - response = HandleRegister(request); - } - else if(sipAuthMethod=="INVITE") - { - response = HandleInvite(request); - } - else - { - m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); - response["int_response_code"]=404; - } + + if (sipAuthMethod=="REGISTER") + { + response = HandleRegister(request); + } + else if (sipAuthMethod=="INVITE") + { + response = HandleInvite(request); + } + else + { + m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); + response["int_response_code"]=404; + } } - else if(eventCallingFunction=="switch_xml_locate_user") - { - response = HandleLocateUser(request); + else if (eventCallingFunction=="switch_xml_locate_user") + { + response = HandleLocateUser(request); } - else if(eventCallingFunction=="user_data_function") // gets called when an avatar to avatar call is made + else if (eventCallingFunction=="user_data_function") // gets called when an avatar to avatar call is made { response = HandleLocateUser(request); } - else if(eventCallingFunction=="user_outgoing_channel") + else if (eventCallingFunction=="user_outgoing_channel") { response = HandleRegister(request); } - else if(eventCallingFunction=="config_sofia") // happens once on freeswitch startup + else if (eventCallingFunction=="config_sofia") // happens once on freeswitch startup { response = HandleConfigSofia(request); } - else if(eventCallingFunction=="switch_load_network_lists") + else if (eventCallingFunction=="switch_load_network_lists") { //response = HandleLoadNetworkLists(request); response["int_response_code"]=404; @@ -266,24 +266,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n"+ "\r\n"+ "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ + "\r\n"+ ""+ "\r\n" + "\r\n"+ @@ -332,4 +332,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } -} \ No newline at end of file +} diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index a8f9de6..fcb1c97 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -500,7 +500,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // is this a dialplan or directory request string section = (string) requestBody["section"]; - if(section=="directory") + if (section=="directory") response = m_FreeSwitchDirectory.HandleDirectoryRequest(requestBody); else if (section=="dialplan") response = m_FreeSwitchDialplan.HandleDialplanRequest(requestBody); -- cgit v1.1 From c397f05be74487d18eb2e60d52dadffc496aa19e Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 22 Apr 2009 06:07:39 +0000 Subject: * Some tweaks to the FreeSwitchModule to allow a well known hostname and avoid a double // in a path which causes account verification to fail * The change shouldn't affect anyone who has it working currently and makes it a ton easier for everyone else to get it working. * Handle a case when there's no Event-Calling-Function but it's obviously a REGISTER method --- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 14 +++++++++++++- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 21 +++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 4113976..24f114d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -69,7 +69,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } string eventCallingFunction = (string) request["Event-Calling-Function"]; - + if (eventCallingFunction == null) + { + eventCallingFunction = "sofia_reg_parse_auth"; + } + + if (eventCallingFunction.Length == 0) + { + eventCallingFunction = "sofia_reg_parse_auth"; + } if (eventCallingFunction=="sofia_reg_parse_auth") { @@ -110,12 +118,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice //response = HandleLoadNetworkLists(request); response["int_response_code"]=404; response["keepalive"] = false; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; } else { m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); response["int_response_code"]=404; response["keepalive"] = false; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index fcb1c97..6fb2c53 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -90,6 +90,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static int m_freeSwitchSubscribeRetry; private static string m_freeSwitchUrlResetPassword; private static IPEndPoint m_FreeSwitchServiceIP; + private int m_freeSwitchServicePort; + private string m_openSimWellKnownHTTPAddress; private FreeSwitchDirectory m_FreeSwitchDirectory; private FreeSwitchDialplan m_FreeSwitchDialplan; @@ -131,7 +133,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice int servicePort = m_config.GetInt("freeswitch_service_port", 80); IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); - + m_freeSwitchServicePort = servicePort; m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); @@ -139,6 +141,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); + m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString()); m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); @@ -306,12 +309,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // those agentname = agentname.Replace('+', '-').Replace('/', '_'); - + // LLSDVoiceAccountResponse voiceAccountResponse = // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, - String.Format("http://{0}/{1}/", m_FreeSwitchServiceIP, + String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); @@ -490,20 +493,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) { - m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}",request.ToString()); + m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); Hashtable response = new Hashtable(); // all the params come as NVPs in the request body Hashtable requestBody = parseRequestBody((string) request["body"]); - + // is this a dialplan or directory request string section = (string) requestBody["section"]; - - if (section=="directory") + + if (section == "directory") response = m_FreeSwitchDirectory.HandleDirectoryRequest(requestBody); - else if (section=="dialplan") + else if (section == "dialplan") response = m_FreeSwitchDialplan.HandleDialplanRequest(requestBody); + else + m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); // XXX: re-generate dialplan: // - conf == region UUID -- cgit v1.1 From 458f7eb9b38609d02980afe5a6ee88d19c7dd7f8 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 22 Apr 2009 09:42:44 +0000 Subject: cleaning up, fixing warnings --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 2 +- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 63 ++++++++++------------ .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 42 +++++++-------- 3 files changed, 46 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index d8fce67..039cc2f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"]=200; + response["int_response_code"] = 200; response["str_response_string"] = @"
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 24f114d..fd384e4 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -65,7 +65,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice foreach (DictionaryEntry item in request) { - m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); + m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value); } string eventCallingFunction = (string) request["Event-Calling-Function"]; @@ -79,44 +79,44 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice eventCallingFunction = "sofia_reg_parse_auth"; } - if (eventCallingFunction=="sofia_reg_parse_auth") + if (eventCallingFunction == "sofia_reg_parse_auth") { string sipAuthMethod = (string)request["sip_auth_method"]; - if (sipAuthMethod=="REGISTER") + if (sipAuthMethod == "REGISTER") { response = HandleRegister(request); } - else if (sipAuthMethod=="INVITE") + else if (sipAuthMethod == "INVITE") { response = HandleInvite(request); } else { m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); - response["int_response_code"]=404; + response["int_response_code"] = 404; } } - else if (eventCallingFunction=="switch_xml_locate_user") + else if (eventCallingFunction == "switch_xml_locate_user") { response = HandleLocateUser(request); } - else if (eventCallingFunction=="user_data_function") // gets called when an avatar to avatar call is made + else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made { response = HandleLocateUser(request); } - else if (eventCallingFunction=="user_outgoing_channel") + else if (eventCallingFunction == "user_outgoing_channel") { response = HandleRegister(request); } - else if (eventCallingFunction=="config_sofia") // happens once on freeswitch startup + else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup { response = HandleConfigSofia(request); } - else if (eventCallingFunction=="switch_load_network_lists") + else if (eventCallingFunction == "switch_load_network_lists") { //response = HandleLoadNetworkLists(request); - response["int_response_code"]=404; + response["int_response_code"] = 404; response["keepalive"] = false; response["content_type"] = "text/xml"; response["str_response_string"] = ""; @@ -124,14 +124,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice else { m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); - response["int_response_code"]=404; + response["int_response_code"] = 404; response["keepalive"] = false; response["content_type"] = "text/xml"; response["str_response_string"] = ""; } - - - return response; } @@ -147,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"]=200; + response["int_response_code"] = 200; response["str_response_string"] = String.Format( "\r\n" + "\r\n" + @@ -165,11 +162,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "
\r\n" + - "
\r\n" - , domain , user, password); + "\r\n", + domain , user, password); return response; - } private Hashtable HandleInvite(Hashtable request) @@ -185,7 +181,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"]=200; + response["int_response_code"] = 200; response["str_response_string"] = String.Format( "\r\n" + "\r\n" + @@ -213,8 +209,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" - , domain , user, password,sipRequestUser); + "\r\n", + domain , user, password,sipRequestUser); return response; } @@ -231,7 +227,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"]=200; + response["int_response_code"] = 200; response["str_response_string"] = String.Format( "\r\n" + "\r\n" + @@ -248,10 +244,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" - , domain , user); - - + "\r\n", + domain , user); return response; } @@ -266,7 +260,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"]=200; + response["int_response_code"] = 200; response["str_response_string"] = String.Format( "\r\n" + "\r\n" + @@ -303,9 +297,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "
\r\n"+ "\r\n" + "\r\n" + - "\r\n" - , domain); - + "\r\n", + domain); return response; } @@ -320,7 +313,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"]=200; + response["int_response_code"] = 200; response["str_response_string"] = String.Format( "\r\n" + "\r\n" + @@ -335,13 +328,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n"+ "\r\n" + "\r\n" + - "\r\n" - , domain); + "\r\n", + domain); return response; } - } - } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 6fb2c53..358f1cd 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -54,7 +54,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // Infrastructure private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static readonly bool DUMP = true; // Capability string prefixes private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; @@ -87,9 +86,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static int m_freeSwitchEchoPort; private static string m_freeSwitchDefaultWellKnownIP; private static int m_freeSwitchDefaultTimeout; - private static int m_freeSwitchSubscribeRetry; + // private static int m_freeSwitchSubscribeRetry; private static string m_freeSwitchUrlResetPassword; - private static IPEndPoint m_FreeSwitchServiceIP; + // private static IPEndPoint m_FreeSwitchServiceIP; private int m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; @@ -132,7 +131,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); int servicePort = m_config.GetInt("freeswitch_service_port", 80); IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); - m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); + // m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); m_freeSwitchServicePort = servicePort; m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); @@ -143,12 +142,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString()); m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); - m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); + // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); - - - if (String.IsNullOrEmpty(m_freeSwitchServerUser) || String.IsNullOrEmpty(m_freeSwitchServerPass) || String.IsNullOrEmpty(m_freeSwitchRealm) || @@ -163,12 +159,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // - prelogin: viv_get_prelogin.php // - signin: viv_signin.php scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceGetPreloginHTTPHandler); + FreeSwitchSLVoiceGetPreloginHTTPHandler); - // RestStreamHandler h = new RestStreamHandler("GET", String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); + // RestStreamHandler h = new + // RestStreamHandler("GET", + // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // scene.CommsManager.HttpServer.AddStreamHandler(h); - - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); @@ -307,15 +303,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // XXX: we need to cache the voice credentials, as // FreeSwitch is later going to come and ask us for // those - agentname = agentname.Replace('+', '-').Replace('/', '_'); // LLSDVoiceAccountResponse voiceAccountResponse = // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); LLSDVoiceAccountResponse voiceAccountResponse = - new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, - String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, m_freeSwitchServicePort, - m_freeSwitchAPIPrefix)); + new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, + String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, + m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); @@ -346,7 +341,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); - string avatarName = avatar.Name; + string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: @@ -460,11 +455,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "{8}\r\n"+ "\r\n"+ "false\r\n"+ - "" - , - m_freeSwitchRealm,m_freeSwitchSIPProxy,m_freeSwitchAttemptUseSTUN, - m_freeSwitchSTUNServer,m_freeSwitchEchoServer,m_freeSwitchEchoPort, - m_freeSwitchDefaultWellKnownIP,m_freeSwitchDefaultTimeout,m_freeSwitchUrlResetPassword,""); + "", + m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, + m_freeSwitchSTUNServer, m_freeSwitchEchoServer, m_freeSwitchEchoPort, + m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, + m_freeSwitchUrlResetPassword, ""); response["int_response_code"] = 200; @@ -531,12 +526,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if (s.Trim() != "") { string [] nvp = s.Split(new Char [] {'='}); - bodyParams.Add(HttpUtility.UrlDecode(nvp[0]),HttpUtility.UrlDecode(nvp[1])); + bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1])); } } return bodyParams; - } private string ChannelUri(Scene scene, LandData land) -- cgit v1.1 From c25ceb009e644579c56811faffded540658cd4dd Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 22 Apr 2009 19:43:58 +0000 Subject: * minor: remove some compiler warnings --- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 62 +++++++++++----------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index fd384e4..c131a7f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -303,36 +303,36 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } - private Hashtable HandleLoadNetworkLists(Hashtable request) - { - m_log.Info("[FreeSwitchDirectory] HandleLoadNetworkLists called"); - - // TODO the password we return needs to match that sent in the request, this is hard coded for now - string domain = (string) request["domain"]; - - Hashtable response = new Hashtable(); - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = String.Format( - "\r\n" + - "\r\n" + - "
\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n" + - "
\r\n" + - "
\r\n", - domain); - - - return response; - } +// private Hashtable HandleLoadNetworkLists(Hashtable request) +// { +// m_log.Info("[FreeSwitchDirectory] HandleLoadNetworkLists called"); +// +// // TODO the password we return needs to match that sent in the request, this is hard coded for now +// string domain = (string) request["domain"]; +// +// Hashtable response = new Hashtable(); +// response["content_type"] = "text/xml"; +// response["keepalive"] = false; +// response["int_response_code"] = 200; +// response["str_response_string"] = String.Format( +// "\r\n" + +// "\r\n" + +// "
\r\n" + +// "\r\n" + +// "\r\n" + +// "\r\n" + +// "\r\n" + +// "\r\n" + +// "\r\n"+ +// "\r\n"+ +// "\r\n"+ +// "\r\n" + +// "
\r\n" + +// "
\r\n", +// domain); +// +// +// return response; +// } } } -- cgit v1.1 From dc640465a834c3ddb586d6a7850fd1805ea2e48f Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 23 Apr 2009 05:22:02 +0000 Subject: * Tweaking the dialstring so the sip_contact_user variable is set to the dialed user. This stops the client from complaining and might be useful later. Resolves the 'unable to parse id from mod_sofia@ip:port' message. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 11 ++++++----- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 5 ++++- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index c131a7f..11797f6 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -153,7 +153,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + "\r\n" + "\r\n" + "\r\n" + @@ -190,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + "\r\n" + "\r\n" + "\r\n" + @@ -200,7 +200,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + "\r\n" + "\r\n" + "\r\n" + @@ -234,7 +234,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "
\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + "\r\n" + "\r\n" + "\r\n"+ @@ -267,7 +267,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "
\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + "\r\n" + "\r\n"+ "\r\n"+ @@ -302,6 +302,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } + // private Hashtable HandleLoadNetworkLists(Hashtable request) // { diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 358f1cd..58f1b3a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -45,6 +45,7 @@ using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Caps = OpenSim.Framework.Communications.Capabilities.Caps; +using System.Text.RegularExpressions; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { @@ -511,7 +512,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // -> TODO Initialise(): keep track of regions via events // re-generate accounts for all avatars // -> TODO Initialise(): keep track of avatars via events - m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",response["str_response_string"]); + Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); + + m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), "")); return response; } -- cgit v1.1 From 77bd7da9ccce7d572c7565b8fdda8e6711ca2643 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 23 Apr 2009 06:31:32 +0000 Subject: * Fix another crash bug in the FreeSwitchVoiceModule --- .../OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 2 ++ .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 11797f6..377a824 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -95,6 +95,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); response["int_response_code"] = 404; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; } } else if (eventCallingFunction == "switch_xml_locate_user") diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 58f1b3a..abe7594 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -492,7 +492,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); Hashtable response = new Hashtable(); - + response["str_response_string"] = string.Empty; // all the params come as NVPs in the request body Hashtable requestBody = parseRequestBody((string) request["body"]); -- cgit v1.1 From 917849eaac7fa8a93079d2279781ce819fa04bd1 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 25 Apr 2009 01:15:34 +0000 Subject: * More debug warning message removal in the FreeSwitchVoiceModule --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 296 +++++++++++++++++++-- 1 file changed, 275 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index abe7594..513d169 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -28,7 +28,9 @@ using System; using System.IO; using System.Net; +using System.Net.Security; using System.Web; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Xml; using System.Collections; @@ -47,6 +49,7 @@ using OpenSim.Region.Framework.Scenes; using Caps = OpenSim.Framework.Communications.Capabilities.Caps; using System.Text.RegularExpressions; + namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { public class FreeSwitchVoiceModule : IRegionModule @@ -56,6 +59,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private const bool UseProxy = false; + // Capability string prefixes private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; @@ -95,7 +100,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private FreeSwitchDirectory m_FreeSwitchDirectory; private FreeSwitchDialplan m_FreeSwitchDialplan; + + private readonly Dictionary m_UUIDName = new Dictionary(); + private IConfig m_config; public void Initialise(Scene scene, IConfigSource config) @@ -159,22 +167,42 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // set up http request handlers for // - prelogin: viv_get_prelogin.php // - signin: viv_signin.php - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceGetPreloginHTTPHandler); - - // RestStreamHandler h = new - // RestStreamHandler("GET", - // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); - // scene.CommsManager.HttpServer.AddStreamHandler(h); + // - buddies: viv_buddy.php + // - ???: viv_watcher.php + // - signout: viv_signout.php + if (UseProxy) + { + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/", m_freeSwitchAPIPrefix), + ForwardProxyRequest); + } + else + { + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceGetPreloginHTTPHandler); + + // RestStreamHandler h = new + // RestStreamHandler("GET", + // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); + // scene.CommsManager.HttpServer.AddStreamHandler(h); + + + + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceSigninHTTPHandler); + + // set up http request handlers to provide + // on-demand FreeSwitch configuration to + // FreeSwitch's mod_curl_xml + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), + FreeSwitchConfigHTTPHandler); + + scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceBuddyHTTPHandler); + } - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceSigninHTTPHandler); - - // set up http request handlers to provide - // on-demand FreeSwitch configuration to - // FreeSwitch's mod_curl_xml - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), - FreeSwitchConfigHTTPHandler); + + + m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); @@ -203,7 +231,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice OnRegisterCaps(scene, agentID, caps); }; - + try + { + ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; + } + catch (NotImplementedException) + { + try + { +#pragma warning disable 0612, 0618 + // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! + ServicePointManager.CertificatePolicy = new MonoCert(); +#pragma warning restore 0612, 0618 + } + catch (Exception) + { + m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); + } + } } } @@ -290,6 +335,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); + if (avatar == null) + { + System.Threading.Thread.Sleep(2000); + avatar = scene.GetScenePresence(agentID); + + if (avatar == null) + return "undef"; + } string avatarName = avatar.Name; try @@ -305,8 +358,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // FreeSwitch is later going to come and ask us for // those agentname = agentname.Replace('+', '-').Replace('/', '_'); - - // LLSDVoiceAccountResponse voiceAccountResponse = + + lock (m_UUIDName) + { + if (m_UUIDName.ContainsKey(agentname)) + { + m_UUIDName[agentname] = avatarName; + } + else + { + m_UUIDName.Add(agentname, avatarName); + } + } + + // LLSDVoiceAccountResponse voiceAccountResponse = // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, @@ -433,6 +498,57 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return "true"; } + public Hashtable ForwardProxyRequest(Hashtable request) + { + m_log.Debug("[PROXYING]: -------------------------------proxying request"); + Hashtable response = new Hashtable(); + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; + response["int_response_code"] = 200; + + string forwardaddress = "https://www.bhr.vivox.com/api2/"; + string body = (string)request["body"]; + string method = (string) request["http-method"]; + string contenttype = (string) request["content-type"]; + string uri = (string) request["uri"]; + uri = uri.Replace("/api/", ""); + forwardaddress += uri; + + + string fwdresponsestr = ""; + int fwdresponsecode = 200; + string fwdresponsecontenttype = "text/xml"; + + + HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress); + forwardreq.Method = method; + forwardreq.ContentType = contenttype; + forwardreq.KeepAlive = false; + + if (method == "POST") + { + byte[] contentreq = Encoding.UTF8.GetBytes(body); + forwardreq.ContentLength = contentreq.Length; + Stream reqStream = forwardreq.GetRequestStream(); + reqStream.Write(contentreq, 0, contentreq.Length); + reqStream.Close(); + } + + HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse(); + Encoding encoding = Encoding.UTF8; + StreamReader fwdresponsestream = new StreamReader(fwdrsp.GetResponseStream(), encoding); + fwdresponsestr = fwdresponsestream.ReadToEnd(); + fwdresponsecontenttype = fwdrsp.ContentType; + fwdresponsecode = (int)fwdrsp.StatusCode; + fwdresponsestream.Close(); + + response["content_type"] = fwdresponsecontenttype; + response["str_response_string"] = fwdresponsestr; + response["int_response_code"] = fwdresponsecode; + + return response; + } + public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) { @@ -468,22 +584,139 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } + public Hashtable FreeSwitchSLVoiceBuddyHTTPHandler(Hashtable request) + { + Hashtable response = new Hashtable(); + response["int_response_code"] = 200; + response["str_response_string"] = string.Empty; + response["content-type"] = "text/xml"; + + Hashtable requestBody = parseRequestBody((string)request["body"]); + + if (!requestBody.ContainsKey("auth_token")) + return response; + + string auth_token = (string)requestBody["auth_token"]; + string[] auth_tokenvals = auth_token.Split(':'); + string username = auth_tokenvals[0]; + int strcount = 0; + + string[] ids = new string[strcount]; + + int iter = -1; + lock (m_UUIDName) + { + strcount = m_UUIDName.Count; + ids = new string[strcount]; + foreach (string s in m_UUIDName.Keys) + { + iter++; + ids[iter] = s; + } + } + StringBuilder resp = new StringBuilder(); + resp.Append(""); + + resp.Append(string.Format(@" + OK + lib_session + {0} + {0} + + ",auth_token)); + /* + lib_session + {0}:{1}:9303959503950:: + {0}:{1}:9303959503950:: + */ + for (int i=0;i + {1} + + sip:{0}@{2} + {0} + {0} + {2} + A + {3} + + ", ids[i],i,m_freeSwitchRealm,dt)); + } + + + + resp.Append(""); + + response["str_response_string"] = resp.ToString(); + Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); + + m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); + return response; + } + public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) { m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); - + string requestbody = (string)request["body"]; + string uri = (string)request["uri"]; + string contenttype = (string)request["content-type"]; + + Hashtable requestBody = parseRequestBody((string)request["body"]); + + string pwd = (string) requestBody["pwd"]; + string userid = (string) requestBody["userid"]; + + string avatarName = string.Empty; + int pos = -1; + lock (m_UUIDName) + { + if (m_UUIDName.ContainsKey(userid)) + { + avatarName = m_UUIDName[userid]; + foreach (string s in m_UUIDName.Keys) + { + pos++; + if (s == userid) + break; + + } + } + } + + m_log.DebugFormat("[FreeSwitchVoice]: AUTH, URI: {0}, Content-Type:{1}, Body{2}", uri, contenttype, + requestbody); Hashtable response = new Hashtable(); - response["str_response_string"] = @" + response["str_response_string"] = string.Format(@" OK 200 + lib_session + {0}:{1}:9303959503950:: + {0}:{1}:9303959503950:: + 1 + {1} + {2} auth successful - "; + ", userid, pos, avatarName); + response["int_response_code"] = 200; return response; + /* + + OKOklib_session + * xMj1QJSc7TA-G7XqcW6QXAg==:1290551700:050d35c6fef96f132f780d8039ff7592:: + * xMj1QJSc7TA-G7XqcW6QXAg==:1290551700:050d35c6fef96f132f780d8039ff7592:: + * 1 + * 7449 + * Teravus Ousley + */ } @@ -569,5 +802,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return channelUri; } + + private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) + { + //if (cert.Subject == "E=root@lindenlab.com, CN=*.vaak.lindenlab.com, O=\"Linden Lab, Inc.\", L=San Francisco, S=California, C=US") + //{ + return true; + //} + + //return false; + } + } + public class MonoCert : ICertificatePolicy + { + #region ICertificatePolicy Members + + public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) + { + return true; + } + + #endregion } } -- cgit v1.1 From c320dca2db5c841976f5a36dab47cd3a8250c825 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 29 Apr 2009 18:11:41 +0000 Subject: * minor: remove some mono compiler warnings --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 513d169..f7001ef 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private const bool UseProxy = false; + private bool UseProxy = false; // Capability string prefixes private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; @@ -598,7 +598,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string auth_token = (string)requestBody["auth_token"]; string[] auth_tokenvals = auth_token.Split(':'); - string username = auth_tokenvals[0]; + //string username = auth_tokenvals[0]; int strcount = 0; string[] ids = new string[strcount]; @@ -667,7 +667,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable requestBody = parseRequestBody((string)request["body"]); - string pwd = (string) requestBody["pwd"]; + //string pwd = (string) requestBody["pwd"]; string userid = (string) requestBody["userid"]; string avatarName = string.Empty; -- cgit v1.1 From 40c2e2e84f50e9a75f26b326a798a280d36687e9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 29 Apr 2009 19:31:48 +0000 Subject: * Add test to check temp profile creation on iar load --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index f7001ef..e04b1ba 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -54,10 +54,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { public class FreeSwitchVoiceModule : IRegionModule { - - // Infrastructure - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool UseProxy = false; -- cgit v1.1 From 257fc5515ac9cb36032c2f44f040c3620ed2f328 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 15:38:36 +0000 Subject: * minor: remove some mono compiler warnings, minor cleanup --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index e04b1ba..ddd0c12 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -594,7 +594,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; string auth_token = (string)requestBody["auth_token"]; - string[] auth_tokenvals = auth_token.Split(':'); + //string[] auth_tokenvals = auth_token.Split(':'); //string username = auth_tokenvals[0]; int strcount = 0; @@ -643,9 +643,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice ", ids[i],i,m_freeSwitchRealm,dt)); } - - - + resp.Append(""); response["str_response_string"] = resp.ToString(); @@ -716,7 +714,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice */ } - public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) { m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); -- cgit v1.1 From acfb5051cd328ab21aba5bfc2878ce84d496a7f1 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 4 May 2009 20:15:39 +0000 Subject: Intermediate commit. WILL NOT COMPILE! --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index ddd0c12..4723a93 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -44,6 +44,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Capabilities; using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Caps = OpenSim.Framework.Communications.Capabilities.Caps; -- cgit v1.1 From 840de6c036570d559ec6924cd8405d3f34a99fdd Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 1 Jun 2009 06:37:14 +0000 Subject: Minor: Change OpenSim to OpenSimulator in older copyright headers and LICENSE.txt. --- .../OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 2 +- .../OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 2 +- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index 039cc2f..89071cd 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 377a824..eee122b 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 4723a93..84d7c4c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * -- cgit v1.1 From a23d64dec1cbf88abc3c7e84664a683dee534e4a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 10 Jun 2009 04:28:56 +0000 Subject: Formatting cleanup. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 10 +++++----- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index eee122b..caec43d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -147,7 +147,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - response["str_response_string"] = String.Format( + response["str_response_string"] = String.Format( "\r\n" + "\r\n" + "
\r\n" + @@ -184,7 +184,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - response["str_response_string"] = String.Format( + response["str_response_string"] = String.Format( "\r\n" + "\r\n" + "
\r\n" + @@ -230,7 +230,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - response["str_response_string"] = String.Format( + response["str_response_string"] = String.Format( "\r\n" + "\r\n" + "
\r\n" + @@ -263,7 +263,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - response["str_response_string"] = String.Format( + response["str_response_string"] = String.Format( "\r\n" + "\r\n" + "
\r\n" + @@ -317,7 +317,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // response["content_type"] = "text/xml"; // response["keepalive"] = false; // response["int_response_code"] = 200; -// response["str_response_string"] = String.Format( +// response["str_response_string"] = String.Format( // "\r\n" + // "\r\n" + // "
\r\n" + diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 84d7c4c..de78f5f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -556,7 +556,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; - response["str_response_string"] = String.Format( + response["str_response_string"] = String.Format( "\r\n" + "\r\n"+ "{0}\r\n" + -- cgit v1.1 From f243dddc04a16a175e52e88fb34d38fb6fb643e5 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Thu, 18 Jun 2009 14:33:35 +0000 Subject: * Corrected CAPS namespaces * "luke, use the sed" --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index de78f5f..ce68522 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -42,12 +42,12 @@ using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using Caps = OpenSim.Framework.Communications.Capabilities.Caps; +using Caps = OpenSim.Framework.Capabilities.Caps; using System.Text.RegularExpressions; -- cgit v1.1 From dfd4e78fc0d8ea9210563d4d374e3459436b5c39 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 19 Jun 2009 12:21:33 +0000 Subject: From: Rob Smart Makes an avatars personal voice indicator work with Freeswitch (though not other avatars indicators) --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 7 +++++++ .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 14 ++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index 89071cd..ad2b7e4 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -70,6 +70,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice + + + + + + + diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index ce68522..469ac2f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -790,22 +790,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice landName, land.LocalID, landUUID); } System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); - channelUri = String.Format("sip:confctl-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); - //channelUri="sip:confctl-3001@9.20.151.43"; - //channelUri="sip:opensimconf-3001@9.20.151.43"; + // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables + // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. + channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); + return channelUri; } private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) { - //if (cert.Subject == "E=root@lindenlab.com, CN=*.vaak.lindenlab.com, O=\"Linden Lab, Inc.\", L=San Francisco, S=California, C=US") - //{ + return true; - //} - - //return false; + } } public class MonoCert : ICertificatePolicy -- cgit v1.1 From c310fb11f492419de60b4bf8e5bb234e4589b336 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 10 Jul 2009 02:22:26 +0000 Subject: Remove all references to HttpServer from CommsManager (all incarnations) Change all uses of the HttpServer properties to use the new singleton --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 469ac2f..5c562ac 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -170,31 +170,31 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // - signout: viv_signout.php if (UseProxy) { - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/", m_freeSwitchAPIPrefix), + MainServer.Instance.AddHTTPHandler(String.Format("{0}/", m_freeSwitchAPIPrefix), ForwardProxyRequest); } else { - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // RestStreamHandler h = new // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); - // scene.CommsManager.HttpServer.AddStreamHandler(h); + // MainServer.Instance.AddStreamHandler(h); - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); // set up http request handlers to provide // on-demand FreeSwitch configuration to // FreeSwitch's mod_curl_xml - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), + MainServer.Instance.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); - scene.CommsManager.HttpServer.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); } -- cgit v1.1 From 7a4abf0def0b2d9a89bec354ad175c342e7f2106 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Sat, 11 Jul 2009 08:16:47 +0000 Subject: From: Dr Scofield & Alan Webb this commit finally adds the VivoxVoiceModule: it supports positional as well as conference call type voice (currently only per region server), region and parcel voice, speaker indication (LL client family), direct avtar-to-avatar voice chat. NOTE: you need to obtain an customer admin account from Vivox to be able to use this module --- DON'T ask me about how to about an admin account, i've NO clue, we just wrote this code. --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 1301 ++++++++++++++++++++ 1 file changed, 1301 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs new file mode 100644 index 0000000..12ad9b8 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -0,0 +1,1301 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Net; +using System.Text; +using System.Xml; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using OpenMetaverse; +using log4net; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using Caps = OpenSim.Framework.Communications.Capabilities.Caps; + +namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice +{ + public class VivoxVoiceModule : ISharedRegionModule + { + + // channel distance model values + public const int CHAN_DIST_NONE = 0; // no attenuation + public const int CHAN_DIST_INVERSE = 1; // inverse distance attenuation + public const int CHAN_DIST_LINEAR = 2; // linear attenuation + public const int CHAN_DIST_EXPONENT = 3; // exponential attenuation + public const int CHAN_DIST_DEFAULT = CHAN_DIST_LINEAR; + + // channel type values + public static readonly string CHAN_TYPE_POSITIONAL = "positional"; + public static readonly string CHAN_TYPE_CHANNEL = "channel"; + public static readonly string CHAN_TYPE_DEFAULT = CHAN_TYPE_POSITIONAL; + + // channel mode values + public static readonly string CHAN_MODE_OPEN = "open"; + public static readonly string CHAN_MODE_LECTURE = "lecture"; + public static readonly string CHAN_MODE_PRESENTATION = "presentation"; + public static readonly string CHAN_MODE_AUDITORIUM = "auditorium"; + public static readonly string CHAN_MODE_DEFAULT = CHAN_MODE_OPEN; + + // unconstrained default values + public const double CHAN_ROLL_OFF_DEFAULT = 2.0; // rate of attenuation + public const double CHAN_ROLL_OFF_MIN = 1.0; + public const double CHAN_ROLL_OFF_MAX = 4.0; + public const int CHAN_MAX_RANGE_DEFAULT = 80; // distance at which channel is silent + public const int CHAN_MAX_RANGE_MIN = 0; + public const int CHAN_MAX_RANGE_MAX = 160; + public const int CHAN_CLAMPING_DISTANCE_DEFAULT = 10; // distance before attenuation applies + public const int CHAN_CLAMPING_DISTANCE_MIN = 0; + public const int CHAN_CLAMPING_DISTANCE_MAX = 160; + + // Infrastructure + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly Object vlock = new Object(); + + // Capability strings + private static readonly string m_parcelVoiceInfoRequestPath = "0107/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0108/"; + private static readonly string m_chatSessionRequestPath = "0109/"; + + // Control info, e.g. vivox server, admin user, admin password + private static bool m_pluginEnabled = false; + private static bool m_adminConnected = false; + + private static string m_vivoxServer; + private static string m_vivoxSipUri; + private static string m_vivoxVoiceAccountApi; + private static string m_vivoxAdminUser; + private static string m_vivoxAdminPassword; + private static string m_authToken = String.Empty; + + private static int m_vivoxChannelDistanceModel; + private static double m_vivoxChannelRollOff; + private static int m_vivoxChannelMaximumRange; + private static string m_vivoxChannelMode; + private static string m_vivoxChannelType; + private static int m_vivoxChannelClampingDistance; + + private static Dictionary m_parents = new Dictionary(); + private static bool m_dumpXml; + + private IConfig m_config; + + public void Initialise(IConfigSource config) + { + + m_config = config.Configs["VivoxVoice"]; + + if (null == m_config) + { + m_log.Info("[VivoxVoice] no config found, plugin disabled"); + return; + } + + if (!m_config.GetBoolean("enabled", false)) + { + m_log.Info("[VivoxVoice] plugin disabled by configuration"); + return; + } + + try + { + // retrieve configuration variables + m_vivoxServer = m_config.GetString("vivox_server", String.Empty); + m_vivoxSipUri = m_config.GetString("vivox_sip_uri", String.Empty); + m_vivoxAdminUser = m_config.GetString("vivox_admin_user", String.Empty); + m_vivoxAdminPassword = m_config.GetString("vivox_admin_password", String.Empty); + + m_vivoxChannelDistanceModel = m_config.GetInt("vivox_channel_distance_model", CHAN_DIST_DEFAULT); + m_vivoxChannelRollOff = m_config.GetDouble("vivox_channel_roll_off", CHAN_ROLL_OFF_DEFAULT); + m_vivoxChannelMaximumRange = m_config.GetInt("vivox_channel_max_range", CHAN_MAX_RANGE_DEFAULT); + m_vivoxChannelMode = m_config.GetString("vivox_channel_mode", CHAN_MODE_DEFAULT).ToLower(); + m_vivoxChannelType = m_config.GetString("vivox_channel_type", CHAN_TYPE_DEFAULT).ToLower(); + m_vivoxChannelClampingDistance = m_config.GetInt("vivox_channel_clamping_distance", + CHAN_CLAMPING_DISTANCE_DEFAULT); + m_dumpXml = m_config.GetBoolean("dump_xml", false); + + // Validate against constraints and default if necessary + if (m_vivoxChannelRollOff < CHAN_ROLL_OFF_MIN || m_vivoxChannelRollOff > CHAN_ROLL_OFF_MAX) + { + m_log.WarnFormat("[VivoxVoice] Invalid value for roll off ({0}), reset to {1}.", + m_vivoxChannelRollOff, CHAN_ROLL_OFF_DEFAULT); + m_vivoxChannelRollOff = CHAN_ROLL_OFF_DEFAULT; + } + + if (m_vivoxChannelMaximumRange < CHAN_MAX_RANGE_MIN || m_vivoxChannelMaximumRange > CHAN_MAX_RANGE_MAX) + { + m_log.WarnFormat("[VivoxVoice] Invalid value for maximum range ({0}), reset to {1}.", + m_vivoxChannelMaximumRange, CHAN_MAX_RANGE_DEFAULT); + m_vivoxChannelMaximumRange = CHAN_MAX_RANGE_DEFAULT; + } + + if (m_vivoxChannelClampingDistance < CHAN_CLAMPING_DISTANCE_MIN || + m_vivoxChannelClampingDistance > CHAN_CLAMPING_DISTANCE_MAX) + { + m_log.WarnFormat("[VivoxVoice] Invalid value for clamping distance ({0}), reset to {1}.", + m_vivoxChannelClampingDistance, CHAN_CLAMPING_DISTANCE_DEFAULT); + m_vivoxChannelClampingDistance = CHAN_CLAMPING_DISTANCE_DEFAULT; + } + + switch (m_vivoxChannelMode) + { + case "open" : break; + case "lecture" : break; + case "presentation" : break; + case "auditorium" : break; + default : + m_log.WarnFormat("[VivoxVoice] Invalid value for channel mode ({0}), reset to {1}.", + m_vivoxChannelMode, CHAN_MODE_DEFAULT); + m_vivoxChannelMode = CHAN_MODE_DEFAULT; + break; + } + + switch (m_vivoxChannelType) + { + case "positional" : break; + case "channel" : break; + default : + m_log.WarnFormat("[VivoxVoice] Invalid value for channel type ({0}), reset to {1}.", + m_vivoxChannelType, CHAN_TYPE_DEFAULT); + m_vivoxChannelType = CHAN_TYPE_DEFAULT; + break; + } + + m_vivoxVoiceAccountApi = String.Format("http://{0}/api2", m_vivoxServer); + + // Admin interface required values + if (String.IsNullOrEmpty(m_vivoxServer) || + String.IsNullOrEmpty(m_vivoxSipUri) || + String.IsNullOrEmpty(m_vivoxAdminUser) || + String.IsNullOrEmpty(m_vivoxAdminPassword)) + { + m_log.Error("[VivoxVoice] plugin mis-configured"); + m_log.Info("[VivoxVoice] plugin disabled: incomplete configuration"); + return; + } + + m_log.InfoFormat("[VivoxVoice] using vivox server {0}", m_vivoxServer); + + // Get admin rights and cleanup any residual channel definition + + DoAdminLogin(); + + m_pluginEnabled = true; + + m_log.Info("[VivoxVoice] plugin enabled"); + + } + catch (Exception e) + { + m_log.ErrorFormat("[VivoxVoice] plugin initialization failed: {0}", e.Message); + m_log.DebugFormat("[VivoxVoice] plugin initialization failed: {0}", e.ToString()); + return; + } + } + + + // Called to indicate that the module has been added to the region + public void AddRegion(Scene scene) + { + + if (m_pluginEnabled) + { + lock (vlock) + { + + string channelId; + + string sceneUUID = scene.RegionInfo.RegionID.ToString(); + string sceneName = scene.RegionInfo.RegionName; + + // Make sure that all local channels are deleted. + // So we have to search for the children, and then do an + // iteration over the set of chidren identified. + // This assumes that there is just one directory per + // region. + + if (VivoxTryGetDirectory(sceneUUID + "D", out channelId)) + { + m_log.DebugFormat("[VivoxVoice]: region {0}: uuid {1}: located directory id {2}", + sceneName, sceneUUID, channelId); + + XmlElement children = VivoxListChildren(channelId); + string count; + + if (XmlFind(children, "response.level0.channel-search.count", out count)) + { + int cnum = Convert.ToInt32(count); + for (int i = 0; i < cnum; i++) + { + string id; + if (XmlFind(children, "response.level0.channel-search.channels.channels.level4.id", i, out id)) + { + if (!IsOK(VivoxDeleteChannel(channelId, id))) + m_log.WarnFormat("[VivoxVoice] Channel delete failed {0}:{1}:{2}", i, channelId, id); + } + } + } + } + else + { + if (!VivoxTryCreateDirectory(sceneUUID + "D", sceneName, out channelId)) + { + m_log.WarnFormat("[VivoxVoice] Create failed <{0}:{1}:{2}>", + "*", sceneUUID, sceneName); + channelId = String.Empty; + } + } + + + // Create a dictionary entry unconditionally. This eliminates the + // need to check for a parent in the core code. The end result is + // the same, if the parent table entry is an empty string, then + // region channels will be created as first-level channels. + + lock (m_parents) + if (m_parents.ContainsKey(sceneUUID)) + { + RemoveRegion(scene); + m_parents.Add(sceneUUID, channelId); + } + else + { + m_parents.Add(sceneUUID, channelId); + } + + } + + // we need to capture scene in an anonymous method + // here as we need it later in the callbacks + scene.EventManager.OnRegisterCaps += delegate(UUID agentID, Caps caps) + { + OnRegisterCaps(scene, agentID, caps); + }; + + } + + } + + // Called to indicate that all loadable modules have now been added + public void RegionLoaded(Scene scene) + { + // Do nothing. + } + + // Called to indicate that the region is going away. + public void RemoveRegion(Scene scene) + { + + if (m_pluginEnabled) + { + lock (vlock) + { + + string channelId; + + string sceneUUID = scene.RegionInfo.RegionID.ToString(); + string sceneName = scene.RegionInfo.RegionName; + + // Make sure that all local channels are deleted. + // So we have to search for the children, and then do an + // iteration over the set of chidren identified. + // This assumes that there is just one directory per + // region. + + if (VivoxTryGetDirectory(sceneUUID + "D", out channelId)) + { + + m_log.DebugFormat("[VivoxVoice]: region {0}: uuid {1}: located directory id {2}", + sceneName, sceneUUID, channelId); + + XmlElement children = VivoxListChildren(channelId); + string count; + + if (XmlFind(children, "response.level0.channel-search.count", out count)) + { + int cnum = Convert.ToInt32(count); + for (int i = 0; i < cnum; i++) + { + string id; + if (XmlFind(children, "response.level0.channel-search.channels.channels.level4.id", i, out id)) + { + if (!IsOK(VivoxDeleteChannel(channelId, id))) + m_log.WarnFormat("[VivoxVoice] Channel delete failed {0}:{1}:{2}", i, channelId, id); + } + } + } + } + + if (!IsOK(VivoxDeleteChannel(null, channelId))) + m_log.WarnFormat("[VivoxVoice] Parent channel delete failed {0}:{1}:{2}", sceneName, sceneUUID, channelId); + + // Remove the channel umbrella entry + + lock (m_parents) + { + if (m_parents.ContainsKey(sceneUUID)) + { + m_parents.Remove(sceneUUID); + } + } + } + } + } + + public void PostInitialise() + { + // Do nothing. + } + + public void Close() + { + if (m_pluginEnabled) + VivoxLogout(); + } + + public string Name + { + get { return "VivoxVoiceModule"; } + } + + public bool IsSharedModule + { + get { return true; } + } + + // + // OnRegisterCaps is invoked via the scene.EventManager + // everytime OpenSim hands out capabilities to a client + // (login, region crossing). We contribute two capabilities to + // the set of capabilities handed back to the client: + // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. + // + // ProvisionVoiceAccountRequest allows the client to obtain + // the voice account credentials for the avatar it is + // controlling (e.g., user name, password, etc). + // + // ParcelVoiceInfoRequest is invoked whenever the client + // changes from one region or parcel to another. + // + // Note that OnRegisterCaps is called here via a closure + // delegate containing the scene of the respective region (see + // Initialise()). + // + public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps) + { + m_log.DebugFormat("[VivoxVoice] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); + + string capsBase = "/CAPS/" + caps.CapsObjectPath; + caps.RegisterHandler("ProvisionVoiceAccountRequest", + new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ProvisionVoiceAccountRequest(scene, request, path, param, + agentID, caps); + })); + caps.RegisterHandler("ParcelVoiceInfoRequest", + new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ParcelVoiceInfoRequest(scene, request, path, param, + agentID, caps); + })); + caps.RegisterHandler("ChatSessionRequest", + new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, + delegate(string request, string path, string param, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return ChatSessionRequest(scene, request, path, param, + agentID, caps); + })); + } + + /// + /// Callback for a client request for Voice Account Details + /// + /// current scene object of the client + /// + /// + /// + /// + /// + /// + public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, + UUID agentID, Caps caps) + { + try + { + + ScenePresence avatar = null; + string avatarName = null; + + if (scene == null) throw new Exception("[VivoxVoice][PROVISIONVOICE] Invalid scene"); + + avatar = scene.GetScenePresence(agentID); + while (avatar == null) + { + Thread.Sleep(100); + avatar = scene.GetScenePresence(agentID); + } + + avatarName = avatar.Name; + + m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID); + m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", + request, path, param); + + XmlElement resp; + bool retry = false; + string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); + string password = new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); + string code = String.Empty; + + agentname = agentname.Replace('+', '-').Replace('/', '_'); + + do + { + resp = VivoxGetAccountInfo(agentname); + + if (XmlFind(resp, "response.level0.status", out code)) + { + if (code != "OK") + { + if (XmlFind(resp, "response.level0.body.code", out code)) + { + // If the request was recognized, then this should be set to something + switch (code) + { + case "201" : // Account expired + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : expired credentials", + avatarName); + m_adminConnected = false; + retry = DoAdminLogin(); + break; + + case "202" : // Missing credentials + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : missing credentials", + avatarName); + break; + + case "212" : // Not authorized + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : not authorized", + avatarName); + break; + + case "300" : // Required parameter missing + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : parameter missing", + avatarName); + break; + + case "403" : // Account does not exist + resp = VivoxCreateAccount(agentname,password); + // Note: This REALLY MUST BE status. Create Account does not return code. + if (XmlFind(resp, "response.level0.status", out code)) + { + switch (code) + { + case "201" : // Account expired + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : expired credentials", + avatarName); + m_adminConnected = false; + retry = DoAdminLogin(); + break; + + case "202" : // Missing credentials + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : missing credentials", + avatarName); + break; + + case "212" : // Not authorized + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : not authorized", + avatarName); + break; + + case "300" : // Required parameter missing + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : parameter missing", + avatarName); + break; + + case "400" : // Create failed + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : create failed", + avatarName); + break; + } + } + break; + + case "404" : // Failed to retrieve account + m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : retrieve failed"); + // [AMW] Sleep and retry for a fixed period? Or just abandon? + break; + } + } + } + } + } while (retry); + + if (code != "OK") + { + m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: Get Account Request failed for \"{0}\"", avatarName); + throw new Exception("Unable to execute request"); + } + + // Unconditionally change the password on each request + VivoxPassword(agentname, password); + + LLSDVoiceAccountResponse voiceAccountResponse = + new LLSDVoiceAccountResponse(agentname, password, m_vivoxSipUri, m_vivoxVoiceAccountApi); + + string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); + + m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); + + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[VivoxVoice][PROVISIONVOICE]: : {0}, retry later", e.Message); + m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: : {0} failed", e.ToString()); + return ""; + } + } + + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// current scene object of the client + /// + /// + /// + /// + /// + /// + public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, + UUID agentID, Caps caps) + { + ScenePresence avatar = scene.GetScenePresence(agentID); + string avatarName = avatar.Name; + + // - check whether we have a region channel in our cache + // - if not: + // create it and cache it + // - send it to the client + // - send channel_uri: as "sip:regionID@m_sipDomain" + try + { + LLSDParcelVoiceInfoResponse parcelVoiceInfo; + string channel_uri; + + if (null == scene.LandChannel) + throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", + scene.RegionInfo.RegionName, avatarName)); + + // get channel_uri: check first whether estate + // settings allow voice, then whether parcel allows + // voice, if all do retrieve or obtain the parcel + // voice channel + LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + + m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", + scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); + // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: avatar \"{0}\": location: {1} {2} {3}", + // avatarName, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); + + // TODO: EstateSettings don't seem to get propagated... + if (!scene.RegionInfo.EstateSettings.AllowVoice) + { + m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", + scene.RegionInfo.RegionName); + channel_uri = String.Empty; + } + + if ((land.Flags & (uint)Parcel.ParcelFlags.AllowVoiceChat) == 0) + { + m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", + scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); + channel_uri = String.Empty; + } + else + { + channel_uri = RegionGetOrCreateChannel(scene, land); + } + + // fill in our response to the client + Hashtable creds = new Hashtable(); + creds["channel_uri"] = channel_uri; + + parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); + string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); + + m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", + scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", + scene.RegionInfo.RegionName, avatarName, e.Message); + m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", + scene.RegionInfo.RegionName, avatarName, e.ToString()); + + return ""; + } + } + + + /// + /// Callback for a client request for a private chat channel + /// + /// current scene object of the client + /// + /// + /// + /// + /// + /// + public string ChatSessionRequest(Scene scene, string request, string path, string param, + UUID agentID, Caps caps) + { + ScenePresence avatar = scene.GetScenePresence(agentID); + string avatarName = avatar.Name; + + m_log.DebugFormat("[VivoxVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", + avatarName, request, path, param); + return "true"; + } + + + private string RegionGetOrCreateChannel(Scene scene, LandData land) + { + + string channelUri = null; + string channelId = null; + + string landUUID; + string landName; + string parentId; + + lock (m_parents) parentId = m_parents[scene.RegionInfo.RegionID.ToString()]; + + // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same + // as the directory ID. Otherwise, it reflects the parcel's ID. + + if (land.LocalID != 1 && (land.Flags & (uint)Parcel.ParcelFlags.UseEstateVoiceChan) == 0) + { + landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); + landUUID = land.GlobalID.ToString(); + m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", + landName, land.LocalID, landUUID); + } + else + { + landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); + landUUID = scene.RegionInfo.RegionID.ToString(); + m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", + landName, land.LocalID, landUUID); + } + + lock (vlock) + { + if (!VivoxTryGetChannel(parentId, landUUID, out channelId, out channelUri) && + !VivoxTryCreateChannel(parentId, landUUID, landName, out channelUri)) + throw new Exception("vivox channel uri not available"); + + m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parent channel id {1}: retrieved parcel channel_uri {2} ", + landName, parentId, channelUri); + + + } + + return channelUri; + } + + + private static readonly string m_vivoxLoginPath = "http://{0}/api2/viv_signin.php?userid={1}&pwd={2}"; + + /// + /// Perform administrative login for Vivox. + /// Returns a hash table containing values returned from the request. + /// + private XmlElement VivoxLogin(string name, string password) + { + string requrl = String.Format(m_vivoxLoginPath, m_vivoxServer, name, password); + return VivoxCall(requrl, false); + } + + + private static readonly string m_vivoxLogoutPath = "http://{0}/api2/viv_signout.php?auth_token={1}"; + + /// + /// Perform administrative logout for Vivox. + /// + private XmlElement VivoxLogout() + { + string requrl = String.Format(m_vivoxLogoutPath, m_vivoxServer, m_authToken); + return VivoxCall(requrl, false); + } + + + private static readonly string m_vivoxGetAccountPath = "http://{0}/api2/viv_get_acct.php?auth_token={1}&user_name={2}"; + + /// + /// Retrieve account information for the specified user. + /// Returns a hash table containing values returned from the request. + /// + private XmlElement VivoxGetAccountInfo(string user) + { + string requrl = String.Format(m_vivoxGetAccountPath, m_vivoxServer, m_authToken, user); + return VivoxCall(requrl, true); + } + + + private static readonly string m_vivoxNewAccountPath = "http://{0}/api2/viv_adm_acct_new.php?username={1}&pwd={2}&auth_token={3}"; + + /// + /// Creates a new account. + /// For now we supply the minimum set of values, which + /// is user name and password. We *can* supply a lot more + /// demographic data. + /// + private XmlElement VivoxCreateAccount(string user, string password) + { + string requrl = String.Format(m_vivoxNewAccountPath, m_vivoxServer, user, password, m_authToken); + return VivoxCall(requrl, true); + } + + + private static readonly string m_vivoxPasswordPath = "http://{0}/api2/viv_adm_password.php?user_name={1}&new_pwd={2}&auth_token={3}"; + + /// + /// Change the user's password. + /// + private XmlElement VivoxPassword(string user, string password) + { + string requrl = String.Format(m_vivoxPasswordPath, m_vivoxServer, user, password, m_authToken); + return VivoxCall(requrl, true); + } + + + private static readonly string m_vivoxChannelPath = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_name={2}&auth_token={3}"; + + /// + /// Create a channel. + /// Once again, there a multitude of options possible. In the simplest case + /// we specify only the name and get a non-persistent cannel in return. Non + /// persistent means that the channel gets deleted if no-one uses it for + /// 5 hours. To accomodate future requirements, it may be a good idea to + /// initially create channels under the umbrella of a parent ID based upon + /// the region name. That way we have a context for side channels, if those + /// are required in a later phase. + /// + /// In this case the call handles parent and description as optional values. + /// + + private bool VivoxTryCreateChannel(string parent, string channelId, string description, out string channelUri) + { + string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", channelId, m_authToken); + + if (parent != null && parent != String.Empty) + { + requrl = String.Format("{0}&chan_parent={1}", requrl, parent); + } + if (description != null && description != String.Empty) + { + requrl = String.Format("{0}&chan_desc={1}", requrl, description); + } + + requrl = String.Format("{0}&chan_type={1}", requrl, m_vivoxChannelType); + requrl = String.Format("{0}&chan_mode={1}", requrl, m_vivoxChannelMode); + requrl = String.Format("{0}&chan_roll_off={1}", requrl, m_vivoxChannelRollOff); + requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel); + requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange); + requrl = String.Format("{0}&chan_ckamping_distance={1}", requrl, m_vivoxChannelClampingDistance); + + XmlElement resp = VivoxCall(requrl, true); + if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri)) + return true; + + channelUri = String.Empty; + return false; + } + + /// + /// Create a directory. + /// Create a channel with an unconditional type of "dir" (indicating directory). + /// This is used to create an arbitrary name tree for partitioning of the + /// channel name space. + /// The parent and description are optional values. + /// + + private bool VivoxTryCreateDirectory(string dirId, string description, out string channelId) + { + string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", dirId, m_authToken); + + // if (parent != null && parent != String.Empty) + // { + // requrl = String.Format("{0}&chan_parent={1}", requrl, parent); + // } + + if (description != null && description != String.Empty) + { + requrl = String.Format("{0}&chan_desc={1}", requrl, description); + } + requrl = String.Format("{0}&chan_type={1}", requrl, "dir"); + + XmlElement resp = VivoxCall(requrl, true); + if (IsOK(resp) && XmlFind(resp, "response.level0.body.chan_id", out channelId)) + return true; + + channelId = String.Empty; + return false; + } + + private static readonly string m_vivoxChannelSearchPath = "http://{0}/api2/viv_chan_search.php?cond_channame={1}&auth_token={2}"; + + /// + /// Retrieve a channel. + /// Once again, there a multitude of options possible. In the simplest case + /// we specify only the name and get a non-persistent cannel in return. Non + /// persistent means that the channel gets deleted if no-one uses it for + /// 5 hours. To accomodate future requirements, it may be a good idea to + /// initially create channels under the umbrella of a parent ID based upon + /// the region name. That way we have a context for side channels, if those + /// are required in a later phase. + /// In this case the call handles parent and description as optional values. + /// + + private bool VivoxTryGetChannel(string channelParent, string channelName, + out string channelId, out string channelUri) + { + string count; + + string requrl = String.Format(m_vivoxChannelSearchPath, m_vivoxServer, channelName, m_authToken); + XmlElement resp = VivoxCall(requrl, true); + + if (XmlFind(resp, "response.level0.channel-search.count", out count)) + { + int channels = Convert.ToInt32(count); + for (int i = 0; i < channels; i++) + { + string name; + string id; + string type; + string uri; + string parent; + + // skip if not a channel + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.type", i, out type) || + (type != "channel" && type != "positional_M")) + continue; + + // skip if not the name we are looking for + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.name", i, out name) || + name != channelName) + continue; + + // skip if parent does not match + if (channelParent != null && !XmlFind(resp, "response.level0.channel-search.channels.channels.level4.parent", i, out parent)) + continue; + + // skip if no channel id available + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.id", i, out id)) + continue; + + // skip if no channel uri available + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.uri", i, out uri)) + continue; + + channelId = id; + channelUri = uri; + + return true; + } + } + + channelId = String.Empty; + channelUri = String.Empty; + return false; + } + + private bool VivoxTryGetDirectory(string directoryName, out string directoryId) + { + string count; + + string requrl = String.Format(m_vivoxChannelSearchPath, m_vivoxServer, directoryName, m_authToken); + XmlElement resp = VivoxCall(requrl, true); + + if (XmlFind(resp, "response.level0.channel-search.count", out count)) + { + int channels = Convert.ToInt32(count); + for (int i = 0; i < channels; i++) + { + string name; + string id; + string type; + + // skip if not a directory + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.type", i, out type) || + type != "dir") + continue; + + // skip if not the name we are looking for + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.name", i, out name) || + name != directoryName) + continue; + + // skip if no channel id available + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.id", i, out id)) + continue; + + directoryId = id; + return true; + } + } + + directoryId = String.Empty; + return false; + } + + // private static readonly string m_vivoxChannelById = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_id={2}&auth_token={3}"; + + // private XmlElement VivoxGetChannelById(string parent, string channelid) + // { + // string requrl = String.Format(m_vivoxChannelById, m_vivoxServer, "get", channelid, m_authToken); + + // if (parent != null && parent != String.Empty) + // return VivoxGetChild(parent, channelid); + // else + // return VivoxCall(requrl, true); + // } + + /// + /// Delete a channel. + /// Once again, there a multitude of options possible. In the simplest case + /// we specify only the name and get a non-persistent cannel in return. Non + /// persistent means that the channel gets deleted if no-one uses it for + /// 5 hours. To accomodate future requirements, it may be a good idea to + /// initially create channels under the umbrella of a parent ID based upon + /// the region name. That way we have a context for side channels, if those + /// are required in a later phase. + /// In this case the call handles parent and description as optional values. + /// + + private static readonly string m_vivoxChannelDel = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_id={2}&auth_token={3}"; + + private XmlElement VivoxDeleteChannel(string parent, string channelid) + { + string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken); + if (parent != null && parent != String.Empty) + { + requrl = String.Format("{0}&chan_parent={1}", requrl, parent); + } + return VivoxCall(requrl, true); + } + + /// + /// Return information on channels in the given directory + /// + + private static readonly string m_vivoxChannelSearch = "http://{0}/api2/viv_chan_search.php?&cond_chanparent={1}&auth_token={2}"; + + private XmlElement VivoxListChildren(string channelid) + { + string requrl = String.Format(m_vivoxChannelSearch, m_vivoxServer, channelid, m_authToken); + return VivoxCall(requrl, true); + } + + // private XmlElement VivoxGetChild(string parent, string child) + // { + + // XmlElement children = VivoxListChildren(parent); + // string count; + + // if (XmlFind(children, "response.level0.channel-search.count", out count)) + // { + // int cnum = Convert.ToInt32(count); + // for (int i = 0; i < cnum; i++) + // { + // string name; + // string id; + // if (XmlFind(children, "response.level0.channel-search.channels.channels.level4.name", i, out name)) + // { + // if (name == child) + // { + // if (XmlFind(children, "response.level0.channel-search.channels.channels.level4.id", i, out id)) + // { + // return VivoxGetChannelById(null, id); + // } + // } + // } + // } + // } + + // // One we *know* does not exist. + // return VivoxGetChannel(null, Guid.NewGuid().ToString()); + + // } + + /// + /// This method handles the WEB side of making a request over the + /// Vivox interface. The returned values are tansferred to a has + /// table which is returned as the result. + /// The outcome of the call can be determined by examining the + /// status value in the hash table. + /// + + private XmlElement VivoxCall(string requrl, bool admin) + { + + XmlDocument doc = null; + + // If this is an admin call, and admin is not connected, + // and the admin id cannot be connected, then fail. + if (admin && !m_adminConnected && !DoAdminLogin()) + return null; + + doc = new XmlDocument(); + + try + { + // Otherwise prepare the request + m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); + HttpWebResponse rsp = null; + + // We are sending just parameters, no content + req.ContentLength = 0; + + // Send request and retrieve the response + rsp = (HttpWebResponse)req.GetResponse(); + + XmlTextReader rdr = new XmlTextReader(rsp.GetResponseStream()); + doc.Load(rdr); + rdr.Close(); + } + catch (Exception e) + { + m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); + } + + // If we're debugging server responses, dump the whole + // load now + if (m_dumpXml) XmlScanl(doc.DocumentElement,0); + + return doc.DocumentElement; + } + + /// + /// Just say if it worked. + /// + + private bool IsOK(XmlElement resp) + { + string status; + XmlFind(resp, "response.level0.status", out status); + return (status == "OK"); + } + + /// + /// Login has been factored in this way because it gets called + /// from several places in the module, and we want it to work + /// the same way each time. + /// + private bool DoAdminLogin() + { + m_log.Debug("[VivoxVoice] Establishing admin connection"); + + lock (vlock) + { + if (!m_adminConnected) + { + string status = "Unknown"; + XmlElement resp = null; + + resp = VivoxLogin(m_vivoxAdminUser, m_vivoxAdminPassword); + + if (XmlFind(resp, "response.level0.body.status", out status)) + { + if (status == "Ok") + { + m_log.Info("[VivoxVoice] Admin connection established"); + if (XmlFind(resp, "response.level0.body.auth_token", out m_authToken)) + { + if (m_dumpXml) m_log.DebugFormat("[VivoxVoice] Auth Token <{0}>", + m_authToken); + m_adminConnected = true; + } + } + else + { + m_log.WarnFormat("[VivoxVoice] Admin connection failed, status = {0}", + status); + } + } + } + } + + return m_adminConnected; + } + + /// + /// The XmlScan routine is provided to aid in the + /// reverse engineering of incompletely + /// documented packets returned by the Vivox + /// voice server. It is only called if the + /// m_dumpXml switch is set. + /// + private void XmlScanl(XmlElement e, int index) + { + if (e.HasChildNodes) + { + m_log.DebugFormat("<{0}>".PadLeft(index+5), e.Name); + XmlNodeList children = e.ChildNodes; + foreach (XmlNode node in children) + switch (node.NodeType) + { + case XmlNodeType.Element : + XmlScanl((XmlElement)node, index+1); + break; + case XmlNodeType.Text : + m_log.DebugFormat("\"{0}\"".PadLeft(index+5), node.Value); + break; + default : + break; + } + m_log.DebugFormat("".PadLeft(index+6), e.Name); + } + else + { + m_log.DebugFormat("<{0}/>".PadLeft(index+6), e.Name); + } + } + + private static readonly char[] C_POINT = {'.'}; + + /// + /// The Find method is passed an element whose + /// inner text is scanned in an attempt to match + /// the name hierarchy passed in the 'tag' parameter. + /// If the whole hierarchy is resolved, the InnerText + /// value at that point is returned. Note that this + /// may itself be a subhierarchy of the entire + /// document. The function returns a boolean indicator + /// of the search's success. The search is performed + /// by the recursive Search method. + /// + private bool XmlFind(XmlElement root, string tag, int nth, out string result) + { + if (root == null || tag == null || tag == String.Empty) + { + result = String.Empty; + return false; + } + return XmlSearch(root,tag.Split(C_POINT),0, ref nth, out result); + } + + private bool XmlFind(XmlElement root, string tag, out string result) + { + int nth = 0; + if (root == null || tag == null || tag == String.Empty) + { + result = String.Empty; + return false; + } + return XmlSearch(root,tag.Split(C_POINT),0, ref nth, out result); + } + + /// + /// XmlSearch is initially called by XmlFind, and then + /// recursively called by itself until the document + /// supplied to XmlFind is either exhausted or the name hierarchy + /// is matched. + /// + /// If the hierarchy is matched, the value is returned in + /// result, and true returned as the function's + /// value. Otherwise the result is set to the empty string and + /// false is returned. + /// + private bool XmlSearch(XmlElement e, string[] tags, int index, ref int nth, out string result) + { + if (index == tags.Length || e.Name != tags[index]) + { + result = String.Empty; + return false; + } + + if (tags.Length-index == 1) + { + if (nth == 0) + { + result = e.InnerText; + return true; + } + else + { + nth--; + result = String.Empty; + return false; + } + } + + if (e.HasChildNodes) + { + XmlNodeList children = e.ChildNodes; + foreach (XmlNode node in children) + { + switch (node.NodeType) + { + case XmlNodeType.Element : + if (XmlSearch((XmlElement)node, tags, index+1, ref nth, out result)) + return true; + break; + + default : + break; + } + } + } + + result = String.Empty; + return false; + } + } +} -- cgit v1.1 From d123c74e37b8018d82db6eb8afbe3747e22731ad Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Sat, 11 Jul 2009 08:16:59 +0000 Subject: fixing missing ReplacableInterface --- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 12ad9b8..773edc0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -40,12 +40,12 @@ using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using Caps = OpenSim.Framework.Communications.Capabilities.Caps; +using Caps = OpenSim.Framework.Capabilities.Caps; namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice { @@ -388,6 +388,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice VivoxLogout(); } + public Type ReplacableInterface + { + get { return null; } + } + public string Name { get { return "VivoxVoiceModule"; } -- cgit v1.1 From 199984cbea45478e850cce39bff8fbec1695ea75 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 12 Jul 2009 01:04:32 +0000 Subject: * Added some noisy debug information to VivoxModule to try debug why GetChannel fails on LBSA/Zaius Plaza. --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 773edc0..5070ecc 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -739,8 +739,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice lock (vlock) { - if (!VivoxTryGetChannel(parentId, landUUID, out channelId, out channelUri) && - !VivoxTryCreateChannel(parentId, landUUID, landName, out channelUri)) + // Added by Adam to help debug channel not availible errors. + if (VivoxTryGetChannel(parentId, landUUID, out channelId, out channelUri)) + m_log.DebugFormat("[VivoxVoice] Found existing channel at " + channelUri); + else if (VivoxTryCreateChannel(parentId, landUUID, landName, out channelUri)) + m_log.DebugFormat("[VivoxVoice] Created new channel at " + channelUri); + else throw new Exception("vivox channel uri not available"); m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parent channel id {1}: retrieved parcel channel_uri {2} ", @@ -956,6 +960,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice channelId = String.Empty; channelUri = String.Empty; + + m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + resp); + return false; } -- cgit v1.1 From c20a4032e2d4253fe0d8a4c79a6e89ef89d4f131 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 12 Jul 2009 01:23:49 +0000 Subject: * More VivoxModule debugging. --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 5070ecc..d5f3b4a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -930,26 +930,41 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice string parent; // skip if not a channel - if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.type", i, out type) || + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.type", i, out type) || (type != "channel" && type != "positional_M")) + { + m_log.Debug("[VivoxVoice] Skipping Channel " + i + " as it's not a channel."); continue; + } // skip if not the name we are looking for if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.name", i, out name) || name != channelName) + { + m_log.Debug("[VivoxVoice] Skipping Channel " + i + " as it has no name."); continue; + } // skip if parent does not match if (channelParent != null && !XmlFind(resp, "response.level0.channel-search.channels.channels.level4.parent", i, out parent)) + { + m_log.Debug("[VivoxVoice] Skipping Channel " + i + "/" + name + " as it's parent doesnt match"); continue; + } // skip if no channel id available if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.id", i, out id)) + { + m_log.Debug("[VivoxVoice] Skipping Channel " + i + "/" + name + " as it has no channel ID"); continue; + } // skip if no channel uri available if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.uri", i, out uri)) + { + m_log.Debug("[VivoxVoice] Skipping Channel " + i + "/" + name + " as it has no channel URI"); continue; + } channelId = id; channelUri = uri; @@ -961,7 +976,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice channelId = String.Empty; channelUri = String.Empty; - m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + resp); + XmlDocument tmpDoc = new XmlDocument(); + tmpDoc.AppendChild(resp); + + m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + tmpDoc.InnerText); return false; } -- cgit v1.1 From a8b40d47d69979763c63c98ab00aa012514ee36b Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 12 Jul 2009 01:31:33 +0000 Subject: * Patch for previous revision. --- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index d5f3b4a..7c1d2c8 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -976,10 +976,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice channelId = String.Empty; channelUri = String.Empty; - XmlDocument tmpDoc = new XmlDocument(); - tmpDoc.AppendChild(resp); - - m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + tmpDoc.InnerText); + m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + resp.InnerText); return false; } -- cgit v1.1 From 50ccf914ca6bd542e8698cd24feb2832681a466c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 12 Jul 2009 01:56:38 +0000 Subject: * More Vivox Fiddling --- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 7c1d2c8..98c39cc 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -972,11 +972,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return true; } } + else + { + m_log.Debug("[VivoxVoice] No channels registered."); + } channelId = String.Empty; channelUri = String.Empty; - m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + resp.InnerText); + m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + resp.InnerXml); return false; } -- cgit v1.1 From 71ab7a1e2d4b613c1d897e26b518c0316b723f95 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 12 Jul 2009 02:16:49 +0000 Subject: * Workaround for a bug in Vivox Server r2978, whereby channel-search.channels.count returns 0 instead of the actual channel count. Should not affect more recent versions of Vivox where this issue has been fixed. --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 98c39cc..f9d6bd2 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -921,6 +921,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice if (XmlFind(resp, "response.level0.channel-search.count", out count)) { int channels = Convert.ToInt32(count); + + // Bug in Vivox Server r2978 where count returns 0 + // Found by Adam + if(channels == 0) + { + for(int j=0;j<100;j++) + { + string tmpId; + if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.id", j, out tmpId)) + break; + + channels = j + 1; + } + } + for (int i = 0; i < channels; i++) { string name; @@ -974,13 +989,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice } else { - m_log.Debug("[VivoxVoice] No channels registered."); + m_log.Debug("[VivoxVoice] No count element?"); } channelId = String.Empty; channelUri = String.Empty; - m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + resp.InnerXml); + // Useful incase something goes wrong. + //m_log.Debug("[VivoxVoice] Could not find channel in XMLRESP: " + resp.InnerXml); return false; } -- cgit v1.1 From eb1a6e9b87ab7fedc035127b8224147deba2d5ab Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 17 Jul 2009 21:06:28 +0000 Subject: * Patch from otakup0pe to help freeswitch play nice with complex existing freeswitch configurations. * Thanks! fixes mantis #3899 --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 91 +++++----- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 201 +++++++++++---------- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 8 +- 3 files changed, 160 insertions(+), 140 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index ad2b7e4..d34b6f1 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -26,18 +26,20 @@ */ using log4net; +using System; using System.Reflection; +using System.Text; using System.Collections; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { public class FreeSwitchDialplan { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public Hashtable HandleDialplanRequest(Hashtable request) + public Hashtable HandleDialplanRequest(string Context, string Realm, Hashtable request) { m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString()); @@ -47,48 +49,55 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); } - + + string requestcontext = (string) request["Hunt-Context"]; response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - response["str_response_string"] = @" - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
"; + if ( Context != requestcontext ) + { + m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context"); + response["str_response_string"] = ""; + } else { + response["str_response_string"] = String.Format(@" + +
+ " + + +/* + + + + + + */ + + @" + + + + + + + + + + + + + + + + + + + + +
+
", Context, Realm); + } - return response; + return response; } } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index caec43d..af5692c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -38,103 +38,111 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public Hashtable HandleDirectoryRequest(Hashtable request) + public Hashtable HandleDirectoryRequest(string Context, string Realm, Hashtable request) { - m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); + Hashtable response = new Hashtable(); + string domain = (string) request["domain"]; + if ( domain != Realm ) { + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"] = 200; + response["str_response_string"] = ""; + } else { + m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); - Hashtable response = new Hashtable(); - // information in the request we might be interested in + // information in the request we might be interested in - // Request 1 sip_auth for users account + // Request 1 sip_auth for users account - //Event-Calling-Function=sofia_reg_parse_auth - //Event-Calling-Line-Number=1494 - //action=sip_auth - //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41) - //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) - //sip_auth_realm=9.20.151.43 - //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) - //sip_contact_host=192.168.0.3 // this shouldnt really be a local IP, investigate STUN servers - //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D - //sip_to_host=9.20.151.43 - //sip_auth_method=REGISTER - //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D - //domain=9.20.151.43 - //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup + //Event-Calling-Function=sofia_reg_parse_auth + //Event-Calling-Line-Number=1494 + //action=sip_auth + //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41) + //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) + //sip_auth_realm=9.20.151.43 + //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) + //sip_contact_host=192.168.0.3 // this shouldnt really be a local IP, investigate STUN servers + //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D + //sip_to_host=9.20.151.43 + //sip_auth_method=REGISTER + //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D + //domain=9.20.151.43 + //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup - foreach (DictionaryEntry item in request) - { - m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value); - } + foreach (DictionaryEntry item in request) + { + m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value); + } - string eventCallingFunction = (string) request["Event-Calling-Function"]; - if (eventCallingFunction == null) - { - eventCallingFunction = "sofia_reg_parse_auth"; - } + string eventCallingFunction = (string) request["Event-Calling-Function"]; + if (eventCallingFunction == null) + { + eventCallingFunction = "sofia_reg_parse_auth"; + } - if (eventCallingFunction.Length == 0) - { - eventCallingFunction = "sofia_reg_parse_auth"; - } + if (eventCallingFunction.Length == 0) + { + eventCallingFunction = "sofia_reg_parse_auth"; + } - if (eventCallingFunction == "sofia_reg_parse_auth") - { - string sipAuthMethod = (string)request["sip_auth_method"]; + if (eventCallingFunction == "sofia_reg_parse_auth") + { + string sipAuthMethod = (string)request["sip_auth_method"]; - if (sipAuthMethod == "REGISTER") - { - response = HandleRegister(request); - } - else if (sipAuthMethod == "INVITE") - { - response = HandleInvite(request); - } - else - { - m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); - response["int_response_code"] = 404; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - } - else if (eventCallingFunction == "switch_xml_locate_user") - { - response = HandleLocateUser(request); - } - else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made - { - response = HandleLocateUser(request); - } - else if (eventCallingFunction == "user_outgoing_channel") - { - response = HandleRegister(request); - } - else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup - { - response = HandleConfigSofia(request); - } - else if (eventCallingFunction == "switch_load_network_lists") - { - //response = HandleLoadNetworkLists(request); - response["int_response_code"] = 404; - response["keepalive"] = false; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - else - { - m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); - response["int_response_code"] = 404; - response["keepalive"] = false; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - return response; + if (sipAuthMethod == "REGISTER") + { + response = HandleRegister(Context, Realm, request); + } + else if (sipAuthMethod == "INVITE") + { + response = HandleInvite(Context, Realm, request); + } + else + { + m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); + response["int_response_code"] = 404; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; + } + } + else if (eventCallingFunction == "switch_xml_locate_user") + { + response = HandleLocateUser(Realm, request); + } + else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made + { + response = HandleLocateUser(Realm, request); + } + else if (eventCallingFunction == "user_outgoing_channel") + { + response = HandleRegister(Context, Realm, request); + } + else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup + { + response = HandleConfigSofia(Context, Realm, request); + } + else if (eventCallingFunction == "switch_load_network_lists") + { + //response = HandleLoadNetworkLists(request); + response["int_response_code"] = 404; + response["keepalive"] = false; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; + } + else + { + m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); + response["int_response_code"] = 404; + response["keepalive"] = false; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; + } + } + return response; } - private Hashtable HandleRegister(Hashtable request) + private Hashtable HandleRegister(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleRegister called"); @@ -147,7 +155,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - response["str_response_string"] = String.Format( + + response["str_response_string"] = String.Format( "\r\n" + "\r\n" + "
\r\n" + @@ -158,19 +167,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + "\r\n" + "
\r\n" + "
\r\n", - domain , user, password); + domain , user, password, Context); return response; } - private Hashtable HandleInvite(Hashtable request) + private Hashtable HandleInvite(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleInvite called"); @@ -195,7 +204,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + @@ -205,20 +214,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + "\r\n" + "
\r\n" + "
\r\n", - domain , user, password,sipRequestUser); + domain , user, password,sipRequestUser, Context); return response; } - private Hashtable HandleLocateUser(Hashtable request) + private Hashtable HandleLocateUser(String Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleLocateUser called"); @@ -252,7 +261,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } - private Hashtable HandleConfigSofia(Hashtable request) + private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called"); @@ -285,7 +294,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n"+ "\r\n"+ "\r\n"+ - "\r\n"+ + "\r\n"+ "\r\n"+ "\r\n"+ "\r\n"+ @@ -300,7 +309,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "
\r\n" + "
\r\n", - domain); + domain, Context); return response; } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 5c562ac..3659299 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -95,6 +95,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // private static IPEndPoint m_FreeSwitchServiceIP; private int m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; + private string m_freeSwitchContext; private FreeSwitchDirectory m_FreeSwitchDirectory; private FreeSwitchDialplan m_FreeSwitchDialplan; @@ -151,6 +152,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); + m_freeSwitchContext = m_config.GetString("freeswitch_context", "public"); if (String.IsNullOrEmpty(m_freeSwitchServerUser) || String.IsNullOrEmpty(m_freeSwitchServerPass) || @@ -572,7 +574,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "false\r\n"+ "", m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, - m_freeSwitchSTUNServer, m_freeSwitchEchoServer, m_freeSwitchEchoPort, + m_freeSwitchEchoServer, m_freeSwitchEchoPort, m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, m_freeSwitchUrlResetPassword, ""); @@ -728,9 +730,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string section = (string) requestBody["section"]; if (section == "directory") - response = m_FreeSwitchDirectory.HandleDirectoryRequest(requestBody); + response = m_FreeSwitchDirectory.HandleDirectoryRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); else if (section == "dialplan") - response = m_FreeSwitchDialplan.HandleDialplanRequest(requestBody); + response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); else m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); -- cgit v1.1 From a133e83f3ab38ad7abf0b3c591421d3eac418c0c Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 23 Jul 2009 15:32:11 +0000 Subject: Formatting cleanup. --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 78 ++++----- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 192 ++++++++++----------- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 4 +- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 4 +- 4 files changed, 138 insertions(+), 140 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index d34b6f1..bb3dca5 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -36,7 +36,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public class FreeSwitchDialplan { private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public Hashtable HandleDialplanRequest(string Context, string Realm, Hashtable request) @@ -54,50 +54,50 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - if ( Context != requestcontext ) - { - m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context"); - response["str_response_string"] = ""; - } else { - response["str_response_string"] = String.Format(@" - -
- " + + if (Context != requestcontext) + { + m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context"); + response["str_response_string"] = ""; + } else { + response["str_response_string"] = String.Format(@" + +
+ " + -/* - - - - - - */ +/* + + + + + + */ - @" - - - - - + @" + + + + + - - - - - - + + + + + + - - - - - + + + + + - -
-
", Context, Realm); - } +
+
+
", Context, Realm); + } - return response; + return response; } } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index af5692c..5d90a8f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -40,109 +40,108 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable HandleDirectoryRequest(string Context, string Realm, Hashtable request) { - Hashtable response = new Hashtable(); - string domain = (string) request["domain"]; - if ( domain != Realm ) { - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = ""; - } else { - m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); - - - // information in the request we might be interested in + Hashtable response = new Hashtable(); + string domain = (string) request["domain"]; + if (domain != Realm) { + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"] = 200; + response["str_response_string"] = ""; + } else { + m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); + + // information in the request we might be interested in - // Request 1 sip_auth for users account + // Request 1 sip_auth for users account - //Event-Calling-Function=sofia_reg_parse_auth - //Event-Calling-Line-Number=1494 - //action=sip_auth - //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41) - //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) - //sip_auth_realm=9.20.151.43 - //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) - //sip_contact_host=192.168.0.3 // this shouldnt really be a local IP, investigate STUN servers - //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D - //sip_to_host=9.20.151.43 - //sip_auth_method=REGISTER - //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D - //domain=9.20.151.43 - //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup + //Event-Calling-Function=sofia_reg_parse_auth + //Event-Calling-Line-Number=1494 + //action=sip_auth + //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41) + //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) + //sip_auth_realm=9.20.151.43 + //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) + //sip_contact_host=192.168.0.3 // this shouldnt really be a local IP, investigate STUN servers + //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D + //sip_to_host=9.20.151.43 + //sip_auth_method=REGISTER + //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D + //domain=9.20.151.43 + //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup - foreach (DictionaryEntry item in request) - { - m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value); - } + foreach (DictionaryEntry item in request) + { + m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value); + } - string eventCallingFunction = (string) request["Event-Calling-Function"]; - if (eventCallingFunction == null) - { - eventCallingFunction = "sofia_reg_parse_auth"; - } + string eventCallingFunction = (string) request["Event-Calling-Function"]; + if (eventCallingFunction == null) + { + eventCallingFunction = "sofia_reg_parse_auth"; + } - if (eventCallingFunction.Length == 0) - { - eventCallingFunction = "sofia_reg_parse_auth"; - } + if (eventCallingFunction.Length == 0) + { + eventCallingFunction = "sofia_reg_parse_auth"; + } - if (eventCallingFunction == "sofia_reg_parse_auth") - { - string sipAuthMethod = (string)request["sip_auth_method"]; + if (eventCallingFunction == "sofia_reg_parse_auth") + { + string sipAuthMethod = (string)request["sip_auth_method"]; - if (sipAuthMethod == "REGISTER") - { - response = HandleRegister(Context, Realm, request); - } - else if (sipAuthMethod == "INVITE") - { - response = HandleInvite(Context, Realm, request); - } - else - { - m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); - response["int_response_code"] = 404; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - } - else if (eventCallingFunction == "switch_xml_locate_user") - { - response = HandleLocateUser(Realm, request); - } - else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made - { - response = HandleLocateUser(Realm, request); - } - else if (eventCallingFunction == "user_outgoing_channel") - { - response = HandleRegister(Context, Realm, request); - } - else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup - { - response = HandleConfigSofia(Context, Realm, request); - } - else if (eventCallingFunction == "switch_load_network_lists") - { - //response = HandleLoadNetworkLists(request); - response["int_response_code"] = 404; - response["keepalive"] = false; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - else - { - m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); - response["int_response_code"] = 404; - response["keepalive"] = false; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - } - return response; + if (sipAuthMethod == "REGISTER") + { + response = HandleRegister(Context, Realm, request); + } + else if (sipAuthMethod == "INVITE") + { + response = HandleInvite(Context, Realm, request); + } + else + { + m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); + response["int_response_code"] = 404; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; + } + } + else if (eventCallingFunction == "switch_xml_locate_user") + { + response = HandleLocateUser(Realm, request); + } + else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made + { + response = HandleLocateUser(Realm, request); + } + else if (eventCallingFunction == "user_outgoing_channel") + { + response = HandleRegister(Context, Realm, request); + } + else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup + { + response = HandleConfigSofia(Context, Realm, request); + } + else if (eventCallingFunction == "switch_load_network_lists") + { + //response = HandleLoadNetworkLists(request); + response["int_response_code"] = 404; + response["keepalive"] = false; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; + } + else + { + m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); + response["int_response_code"] = 404; + response["keepalive"] = false; + response["content_type"] = "text/xml"; + response["str_response_string"] = ""; + } + } + return response; } - private Hashtable HandleRegister(string Context, string Realm, Hashtable request) + private Hashtable HandleRegister(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleRegister called"); @@ -156,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["keepalive"] = false; response["int_response_code"] = 200; - response["str_response_string"] = String.Format( + response["str_response_string"] = String.Format( "\r\n" + "\r\n" + "
\r\n" + @@ -225,8 +224,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } - - + private Hashtable HandleLocateUser(String Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleLocateUser called"); diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 3659299..de12b0a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -95,7 +95,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // private static IPEndPoint m_FreeSwitchServiceIP; private int m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; - private string m_freeSwitchContext; + private string m_freeSwitchContext; private FreeSwitchDirectory m_FreeSwitchDirectory; private FreeSwitchDialplan m_FreeSwitchDialplan; @@ -152,7 +152,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); - m_freeSwitchContext = m_config.GetString("freeswitch_context", "public"); + m_freeSwitchContext = m_config.GetString("freeswitch_context", "public"); if (String.IsNullOrEmpty(m_freeSwitchServerUser) || String.IsNullOrEmpty(m_freeSwitchServerPass) || diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index f9d6bd2..47309d0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -924,9 +924,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // Bug in Vivox Server r2978 where count returns 0 // Found by Adam - if(channels == 0) + if (channels == 0) { - for(int j=0;j<100;j++) + for (int j=0;j<100;j++) { string tmpId; if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.id", j, out tmpId)) -- cgit v1.1 From 64bd9a335444379ebe1cad8e34d5b5953a76f671 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 25 Jul 2009 15:49:10 +0000 Subject: * Updates libOMV to version 0.7.0 * Uses mantis #3811 as a base (thanks jhuliman) with changes. * E-mail regarding interface changes sent to the opensim-dev list * Archive: https://lists.berlios.de/pipermail/opensim-dev/2009-July/007219.html --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 4 ++-- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index de12b0a..5fa7efd 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -443,7 +443,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // } // else - if ((land.Flags & (uint)Parcel.ParcelFlags.AllowVoiceChat) == 0) + if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); @@ -777,7 +777,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same // as the directory ID. Otherwise, it reflects the parcel's ID. - if (land.LocalID != 1 && (land.Flags & (uint)Parcel.ParcelFlags.UseEstateVoiceChan) == 0) + if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0) { landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); landUUID = land.GlobalID.ToString(); diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 47309d0..5465678 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -651,7 +651,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice channel_uri = String.Empty; } - if ((land.Flags & (uint)Parcel.ParcelFlags.AllowVoiceChat) == 0) + if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); @@ -722,7 +722,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same // as the directory ID. Otherwise, it reflects the parcel's ID. - if (land.LocalID != 1 && (land.Flags & (uint)Parcel.ParcelFlags.UseEstateVoiceChan) == 0) + if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0) { landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); landUUID = land.GlobalID.ToString(); -- cgit v1.1 From fa20a2685bc7bb94ef0f963cae0ebee38cdc9724 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 4 Aug 2009 00:38:20 +0100 Subject: Output the Freeswitch context received and the context set up in the debugging message so a mismatch can be corrected more easily --- .../OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index bb3dca5..703c1e7 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["int_response_code"] = 200; if (Context != requestcontext) { - m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context"); + m_log.DebugFormat("[FreeSwitchDirectory] returning empty as it's for context {0} and we are using {1}", requestcontext, Context); response["str_response_string"] = ""; } else { response["str_response_string"] = String.Format(@" -- cgit v1.1 From 1f90d2a2c6872ff1c6349f86b68de79b17b9de36 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 4 Aug 2009 00:43:49 +0100 Subject: If the FreeSwitch context is unset or "public", then accept any context. This restores the "out of the box" functionality. --- .../OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index 703c1e7..94f29ea 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - if (Context != requestcontext) + if (Context != requestcontext && Context != "public") { m_log.DebugFormat("[FreeSwitchDirectory] returning empty as it's for context {0} and we are using {1}", requestcontext, Context); response["str_response_string"] = ""; -- cgit v1.1 From c3dd98b016c8770c61525bd4d6ca898c635358ed Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 4 Aug 2009 05:03:32 +0100 Subject: Revert the #3899 patch and it's two follow ups --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 25 ++++------- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 48 ++++++++++------------ .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 8 ++-- 3 files changed, 32 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index 94f29ea..c05d598 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -26,9 +26,7 @@ */ using log4net; -using System; using System.Reflection; -using System.Text; using System.Collections; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice @@ -39,7 +37,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public Hashtable HandleDialplanRequest(string Context, string Realm, Hashtable request) + public Hashtable HandleDialplanRequest(Hashtable request) { m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString()); @@ -50,32 +48,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); } - string requestcontext = (string) request["Hunt-Context"]; response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; - if (Context != requestcontext && Context != "public") - { - m_log.DebugFormat("[FreeSwitchDirectory] returning empty as it's for context {0} and we are using {1}", requestcontext, Context); - response["str_response_string"] = ""; - } else { - response["str_response_string"] = String.Format(@" + response["str_response_string"] = @"
- " + + -/* + - */ + - @" + - + @@ -94,8 +86,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
-
", Context, Realm); - } + "; return response; } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 5d90a8f..0a9f69d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -38,18 +38,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public Hashtable HandleDirectoryRequest(string Context, string Realm, Hashtable request) + public Hashtable HandleDirectoryRequest(Hashtable request) { - Hashtable response = new Hashtable(); - string domain = (string) request["domain"]; - if (domain != Realm) { - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = ""; - } else { m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); + Hashtable response = new Hashtable(); + // information in the request we might be interested in // Request 1 sip_auth for users account @@ -91,11 +85,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if (sipAuthMethod == "REGISTER") { - response = HandleRegister(Context, Realm, request); + response = HandleRegister(request); } else if (sipAuthMethod == "INVITE") { - response = HandleInvite(Context, Realm, request); + response = HandleInvite(request); } else { @@ -107,19 +101,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } else if (eventCallingFunction == "switch_xml_locate_user") { - response = HandleLocateUser(Realm, request); + response = HandleLocateUser(request); } else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made { - response = HandleLocateUser(Realm, request); + response = HandleLocateUser(request); } else if (eventCallingFunction == "user_outgoing_channel") { - response = HandleRegister(Context, Realm, request); + response = HandleRegister(request); } else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup { - response = HandleConfigSofia(Context, Realm, request); + response = HandleConfigSofia(request); } else if (eventCallingFunction == "switch_load_network_lists") { @@ -137,11 +131,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["str_response_string"] = ""; } - } return response; } - private Hashtable HandleRegister(string Context, string Realm, Hashtable request) + private Hashtable HandleRegister(Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleRegister called"); @@ -166,19 +159,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + "\r\n" + "
\r\n" + "
\r\n", - domain , user, password, Context); + domain , user, password); return response; } - private Hashtable HandleInvite(string Context, string Realm, Hashtable request) + private Hashtable HandleInvite(Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleInvite called"); @@ -203,7 +196,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + @@ -213,19 +206,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + "\r\n" + "
\r\n" + "
\r\n", - domain , user, password,sipRequestUser, Context); + domain , user, password,sipRequestUser); return response; } - private Hashtable HandleLocateUser(String Realm, Hashtable request) + + private Hashtable HandleLocateUser(Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleLocateUser called"); @@ -259,7 +253,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } - private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request) + private Hashtable HandleConfigSofia(Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called"); @@ -292,7 +286,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n"+ "\r\n"+ "\r\n"+ - "\r\n"+ + "\r\n"+ "\r\n"+ "\r\n"+ "\r\n"+ @@ -307,7 +301,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "
\r\n" + "
\r\n", - domain, Context); + domain); return response; } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 5fa7efd..f9cb1c4 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -95,7 +95,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // private static IPEndPoint m_FreeSwitchServiceIP; private int m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; - private string m_freeSwitchContext; private FreeSwitchDirectory m_FreeSwitchDirectory; private FreeSwitchDialplan m_FreeSwitchDialplan; @@ -152,7 +151,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); - m_freeSwitchContext = m_config.GetString("freeswitch_context", "public"); if (String.IsNullOrEmpty(m_freeSwitchServerUser) || String.IsNullOrEmpty(m_freeSwitchServerPass) || @@ -574,7 +572,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "false\r\n"+ "", m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, - m_freeSwitchEchoServer, m_freeSwitchEchoPort, + m_freeSwitchSTUNServer, m_freeSwitchEchoServer, m_freeSwitchEchoPort, m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, m_freeSwitchUrlResetPassword, ""); @@ -730,9 +728,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string section = (string) requestBody["section"]; if (section == "directory") - response = m_FreeSwitchDirectory.HandleDirectoryRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); + response = m_FreeSwitchDirectory.HandleDirectoryRequest(requestBody); else if (section == "dialplan") - response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); + response = m_FreeSwitchDialplan.HandleDialplanRequest(requestBody); else m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); -- cgit v1.1 From 7fc9358ec36b40c8226a0d76fd9cb5ae70151b5e Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 8 Aug 2009 03:29:00 +0100 Subject: Patch from otakup0pe: A better solution for making the FreeSwitch module cooperate with existing installations --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 29 ++++++++----- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 48 ++++++++++++---------- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 8 ++-- 3 files changed, 51 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index c05d598..b1f93e9 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -26,7 +26,9 @@ */ using log4net; +using System; using System.Reflection; +using System.Text; using System.Collections; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice @@ -37,7 +39,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public Hashtable HandleDialplanRequest(Hashtable request) + public Hashtable HandleDialplanRequest(string Context, string Realm, Hashtable request) { m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString()); @@ -48,33 +50,39 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); } + string requestcontext = (string) request["Hunt-Context"]; response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = @" + response["int_response_code"] = 200; + if ( Context != String.Empty && Context != requestcontext) + { + m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context"); + response["str_response_string"] = ""; + } else { + response["str_response_string"] = String.Format(@"
- + " + - +/* - + */ - + @" - + - + @@ -86,7 +94,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
-
"; + ", Context, Realm); + } return response; } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 0a9f69d..8afaeea 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -38,12 +38,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public Hashtable HandleDirectoryRequest(Hashtable request) + public Hashtable HandleDirectoryRequest(string Context, string Realm, Hashtable request) { + Hashtable response = new Hashtable(); + string domain = (string) request["domain"]; + if ( domain != Realm) { + response["content_type"] = "text/xml"; + response["keepalive"] = false; + response["int_response_code"] = 200; + response["str_response_string"] = ""; + } else { m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); - Hashtable response = new Hashtable(); - // information in the request we might be interested in // Request 1 sip_auth for users account @@ -85,11 +91,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if (sipAuthMethod == "REGISTER") { - response = HandleRegister(request); + response = HandleRegister(Context, Realm, request); } else if (sipAuthMethod == "INVITE") { - response = HandleInvite(request); + response = HandleInvite(Context, Realm, request); } else { @@ -101,19 +107,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } else if (eventCallingFunction == "switch_xml_locate_user") { - response = HandleLocateUser(request); + response = HandleLocateUser(Realm, request); } else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made { - response = HandleLocateUser(request); + response = HandleLocateUser(Realm, request); } else if (eventCallingFunction == "user_outgoing_channel") { - response = HandleRegister(request); + response = HandleRegister(Context, Realm, request); } else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup { - response = HandleConfigSofia(request); + response = HandleConfigSofia(Context, Realm, request); } else if (eventCallingFunction == "switch_load_network_lists") { @@ -131,10 +137,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = "text/xml"; response["str_response_string"] = ""; } + } return response; } - private Hashtable HandleRegister(Hashtable request) + private Hashtable HandleRegister(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleRegister called"); @@ -159,19 +166,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + "\r\n" + "
\r\n" + "
\r\n", - domain , user, password); + domain , user, password, Context); return response; } - private Hashtable HandleInvite(Hashtable request) + private Hashtable HandleInvite(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleInvite called"); @@ -196,7 +203,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + @@ -206,20 +213,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n" + "\r\n" + "\r\n" + - "\r\n" + + "\r\n" + ""+ "\r\n" + "\r\n" + "
\r\n" + "
\r\n" + "\r\n", - domain , user, password,sipRequestUser); + domain , user, password,sipRequestUser, Context); return response; } - - private Hashtable HandleLocateUser(Hashtable request) + private Hashtable HandleLocateUser(String Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleLocateUser called"); @@ -253,7 +259,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } - private Hashtable HandleConfigSofia(Hashtable request) + private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request) { m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called"); @@ -286,7 +292,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n"+ "\r\n"+ "\r\n"+ - "\r\n"+ + "\r\n"+ "\r\n"+ "\r\n"+ "\r\n"+ @@ -301,7 +307,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "
\r\n" + "
\r\n" + "\r\n", - domain); + domain, Context); return response; } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index f9cb1c4..faa0157 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -95,6 +95,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // private static IPEndPoint m_FreeSwitchServiceIP; private int m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; + private string m_freeSwitchContext; private FreeSwitchDirectory m_FreeSwitchDirectory; private FreeSwitchDialplan m_FreeSwitchDialplan; @@ -151,6 +152,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); + m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); if (String.IsNullOrEmpty(m_freeSwitchServerUser) || String.IsNullOrEmpty(m_freeSwitchServerPass) || @@ -572,7 +574,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "false\r\n"+ "", m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, - m_freeSwitchSTUNServer, m_freeSwitchEchoServer, m_freeSwitchEchoPort, + m_freeSwitchEchoServer, m_freeSwitchEchoPort, m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, m_freeSwitchUrlResetPassword, ""); @@ -728,9 +730,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string section = (string) requestBody["section"]; if (section == "directory") - response = m_FreeSwitchDirectory.HandleDirectoryRequest(requestBody); + response = m_FreeSwitchDirectory.HandleDirectoryRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); else if (section == "dialplan") - response = m_FreeSwitchDialplan.HandleDialplanRequest(requestBody); + response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); else m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); -- cgit v1.1 From bc6ec3b56469f2d722ceee8fdb37059125878f66 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 9 Aug 2009 00:43:13 +0900 Subject: Formatting cleanup. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 4 ++-- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index b1f93e9..9ba09ed 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -53,8 +53,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string requestcontext = (string) request["Hunt-Context"]; response["content_type"] = "text/xml"; response["keepalive"] = false; - response["int_response_code"] = 200; - if ( Context != String.Empty && Context != requestcontext) + response["int_response_code"] = 200; + if (Context != String.Empty && Context != requestcontext) { m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context"); response["str_response_string"] = ""; diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 8afaeea..5d90a8f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { Hashtable response = new Hashtable(); string domain = (string) request["domain"]; - if ( domain != Realm) { + if (domain != Realm) { response["content_type"] = "text/xml"; response["keepalive"] = false; response["int_response_code"] = 200; -- cgit v1.1 From eba23048ca2d6dd1b934e11dc426093e5b2134c7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 10 Aug 2009 23:08:22 +0100 Subject: Replace the Replaceable modules name --- .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 5465678..febb491 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -388,7 +388,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice VivoxLogout(); } - public Type ReplacableInterface + public Type ReplaceableInterface { get { return null; } } -- cgit v1.1 From 05756e1fb96aa47f9ff111dd04499934c7077731 Mon Sep 17 00:00:00 2001 From: dr scofield (aka dirk husemann) Date: Wed, 2 Sep 2009 09:43:22 +0200 Subject: warnings safari. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index faa0157..65c5274 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -85,7 +85,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static string m_freeSwitchRealm; private static string m_freeSwitchSIPProxy; private static bool m_freeSwitchAttemptUseSTUN; - private static string m_freeSwitchSTUNServer; + // private static string m_freeSwitchSTUNServer; private static string m_freeSwitchEchoServer; private static int m_freeSwitchEchoPort; private static string m_freeSwitchDefaultWellKnownIP; @@ -144,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); - m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); + // m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); -- cgit v1.1 From 4f3975f04e7bbaf7b7b8e286831714240ced5e6d Mon Sep 17 00:00:00 2001 From: Rob Smart Date: Fri, 18 Sep 2009 14:11:38 +0100 Subject: addition of a new script function osSetParcelSIPAddress(string SIPAddress), now including iVoiceModule This patch allows the land owner to dynamically set the SIP address of a particular land parcel from script. This allows predetermined SIP addresses to be used, making it easier to allow non OpenSim users to join a regions voice channel. Signed-off-by: dr scofield (aka dirk husemann) --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 55 ++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 65c5274..6b30959 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -53,7 +53,7 @@ using System.Text.RegularExpressions; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { - public class FreeSwitchVoiceModule : IRegionModule + public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -101,13 +101,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private FreeSwitchDialplan m_FreeSwitchDialplan; private readonly Dictionary m_UUIDName = new Dictionary(); + private Dictionary m_ParcelAddress = new Dictionary(); + + private Scene m_scene; private IConfig m_config; public void Initialise(Scene scene, IConfigSource config) { - + m_scene = scene; m_config = config.Configs["FreeSwitchVoice"]; if (null == m_config) @@ -230,6 +233,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { OnRegisterCaps(scene, agentID, caps); }; + + try { @@ -255,6 +260,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public void PostInitialise() { + if(m_pluginEnabled) + { + m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); + + // register the voice interface for this module, so the script engine can call us + m_scene.RegisterModuleInterface(this); + } } public void Close() @@ -270,7 +282,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { get { return true; } } - + + // + // implementation of IVoiceModule, called by osSetParcelSIPAddress script function + // + public void setLandSIPAddress(string SIPAddress,UUID GlobalID) + { + m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}", + GlobalID, SIPAddress); + + lock (m_ParcelAddress) + { + if (m_ParcelAddress.ContainsKey(GlobalID.ToString())) + { + m_ParcelAddress[GlobalID.ToString()] = SIPAddress; + } + else + { + m_ParcelAddress.Add(GlobalID.ToString(), SIPAddress); + } + } + } // // OnRegisterCaps is invoked via the scene.EventManager @@ -776,6 +808,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same // as the directory ID. Otherwise, it reflects the parcel's ID. + + lock (m_ParcelAddress) + { + if (m_ParcelAddress.ContainsKey( land.GlobalID.ToString() )) + { + m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", + land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]); + return m_ParcelAddress[land.GlobalID.ToString()]; + } + } if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0) { @@ -797,6 +839,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); + lock (m_ParcelAddress) + { + if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) + { + m_ParcelAddress.Add(land.GlobalID.ToString(),channelUri); + } + } return channelUri; } -- cgit v1.1 From f00126dc2dfc9e23aa50227f02ee9adbe1efdfa6 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 29 Sep 2009 08:32:59 +0900 Subject: Add copyright header. Formatting cleanup. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 6b30959..c7bb56a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -260,12 +260,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public void PostInitialise() { - if(m_pluginEnabled) + if (m_pluginEnabled) { - m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); - - // register the voice interface for this module, so the script engine can call us - m_scene.RegisterModuleInterface(this); + m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); + + // register the voice interface for this module, so the script engine can call us + m_scene.RegisterModuleInterface(this); } } @@ -811,7 +811,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice lock (m_ParcelAddress) { - if (m_ParcelAddress.ContainsKey( land.GlobalID.ToString() )) + if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) { m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]); -- cgit v1.1 From ee205e7e812e170f670e690a4e0fa9caa652f226 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 01:00:09 +0900 Subject: Formatting cleanup. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 4 ++-- .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 18 +++++++++--------- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs index 9ba09ed..46ad30f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs @@ -97,8 +97,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice ", Context, Realm); } - return response; - } + return response; + } } } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index 5d90a8f..df6e0e7 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -138,7 +138,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["str_response_string"] = ""; } } - return response; + return response; } private Hashtable HandleRegister(string Context, string Realm, Hashtable request) @@ -309,17 +309,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "\r\n", domain, Context); - return response; - } + return response; + } // private Hashtable HandleLoadNetworkLists(Hashtable request) // { // m_log.Info("[FreeSwitchDirectory] HandleLoadNetworkLists called"); -// +// // // TODO the password we return needs to match that sent in the request, this is hard coded for now // string domain = (string) request["domain"]; -// +// // Hashtable response = new Hashtable(); // response["content_type"] = "text/xml"; // response["keepalive"] = false; @@ -340,9 +340,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // "\r\n" + // "\r\n", // domain); -// -// -// return response; -// } +// +// +// return response; +// } } } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index febb491..cb76200 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -226,7 +226,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice m_log.DebugFormat("[VivoxVoice] plugin initialization failed: {0}", e.ToString()); return; } - } + } // Called to indicate that the module has been added to the region @@ -1144,7 +1144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // Otherwise prepare the request m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); - HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); HttpWebResponse rsp = null; // We are sending just parameters, no content -- cgit v1.1 From 606e831ff5337fb5e94dcebf9d6852bd4c434d4b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 09:38:36 +0900 Subject: Formatting cleanup. --- .../OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs index df6e0e7..17cdf74 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { response = HandleRegister(Context, Realm, request); } - else if (sipAuthMethod == "INVITE") + else if (sipAuthMethod == "INVITE") { response = HandleInvite(Context, Realm, request); } -- cgit v1.1 From 387e9f7a7faeb412054383080afc3507a1522746 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 2 Oct 2009 18:31:08 -0700 Subject: * Creates Util.UTF8 and switches some references of Encoding.UTF8 to Util.UTF8 (not all references were switched since not all OpenSim libraries reference OpenSim.Framework) * Shrinks the largest in-memory object, the LLRAW.HeightmapLookupValue struct (only used for exporting to LLRAW terrain files), to the minimum possible size. This seems to have the odd side effect of cutting the size of the two double[256,256] terrain objects in half. Possibly an alignment optimization? --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 65c5274..f9dfc0d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -527,7 +527,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if (method == "POST") { - byte[] contentreq = Encoding.UTF8.GetBytes(body); + byte[] contentreq = Util.UTF8.GetBytes(body); forwardreq.ContentLength = contentreq.Length; Stream reqStream = forwardreq.GetRequestStream(); reqStream.Write(contentreq, 0, contentreq.Length); @@ -535,7 +535,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse(); - Encoding encoding = Encoding.UTF8; + Encoding encoding = Util.UTF8; StreamReader fwdresponsestream = new StreamReader(fwdrsp.GetResponseStream(), encoding); fwdresponsestr = fwdresponsestream.ReadToEnd(); fwdresponsecontenttype = fwdrsp.ContentType; -- cgit v1.1 From c5ea783526611a968400a1936e4c6764ee1c7013 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 Jan 2010 07:51:33 -0800 Subject: OpenSim/Framework/Communications/Cache deleted. LibraryRootFolder deleted. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 2 +- .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index b04b076..51341de 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -41,7 +41,7 @@ using log4net; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index cb76200..34d0e24 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -39,7 +39,7 @@ using log4net; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; -- cgit v1.1 From ec3c31e61e5e540f822891110df9bc978655bbaf Mon Sep 17 00:00:00 2001 From: Revolution Date: Fri, 22 Jan 2010 18:09:33 -0600 Subject: Updates all IRegionModules to the new style region modules. Signed-off-by: Melanie --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 72 ++++++++++++++++------ 1 file changed, 52 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index b04b076..23ae307 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -38,6 +38,7 @@ using System.Collections.Generic; using System.Reflection; using OpenMetaverse; using log4net; +using Mono.Addins; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; @@ -53,7 +54,8 @@ using System.Text.RegularExpressions; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { - public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class FreeSwitchVoiceModule : ISharedRegionModule, IVoiceModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -108,9 +110,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private IConfig m_config; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - m_scene = scene; m_config = config.Configs["FreeSwitchVoice"]; if (null == m_config) @@ -224,17 +225,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return; } } + } - if (m_pluginEnabled) + public void AddRegion(Scene scene) + { + m_scene = scene; + if (m_pluginEnabled) { // we need to capture scene in an anonymous method // here as we need it later in the callbacks scene.EventManager.OnRegisterCaps += delegate(UUID agentID, Caps caps) - { - OnRegisterCaps(scene, agentID, caps); - }; - - + { + OnRegisterCaps(scene, agentID, caps); + }; + + try { @@ -254,33 +259,60 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } - + } - } - - public void PostInitialise() - { if (m_pluginEnabled) { m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); - + // register the voice interface for this module, so the script engine can call us m_scene.RegisterModuleInterface(this); } } - public void Close() + public void RegionLoaded(Scene scene) { } - public string Name + public void RemoveRegion(Scene scene) + { + if (UseProxy) + { + MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/", m_freeSwitchAPIPrefix)); + } + else + { + MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix)); + + MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix)); + + MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix)); + + MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix)); + } + scene.EventManager.OnRegisterCaps -= delegate(UUID agentID, Caps caps) + { + OnRegisterCaps(scene, agentID, caps); + }; + scene.UnregisterModuleInterface(this); + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void PostInitialise() { - get { return "FreeSwitchVoiceModule"; } } - public bool IsSharedModule + public void Close() { - get { return true; } + } + + public string Name + { + get { return "FreeSwitchVoiceModule"; } } // -- cgit v1.1 From a87a247f0548d39a8c39b1d28123d7da8db44598 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 29 Jan 2010 07:20:13 +0000 Subject: Revert "Updates all IRegionModules to the new style region modules." This reverts commit ec3c31e61e5e540f822891110df9bc978655bbaf. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 72 ++++++---------------- 1 file changed, 20 insertions(+), 52 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 23ae307..b04b076 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -38,7 +38,6 @@ using System.Collections.Generic; using System.Reflection; using OpenMetaverse; using log4net; -using Mono.Addins; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; @@ -54,8 +53,7 @@ using System.Text.RegularExpressions; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class FreeSwitchVoiceModule : ISharedRegionModule, IVoiceModule + public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -110,8 +108,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private IConfig m_config; - public void Initialise(IConfigSource config) + public void Initialise(Scene scene, IConfigSource config) { + m_scene = scene; m_config = config.Configs["FreeSwitchVoice"]; if (null == m_config) @@ -225,21 +224,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return; } } - } - public void AddRegion(Scene scene) - { - m_scene = scene; - if (m_pluginEnabled) + if (m_pluginEnabled) { // we need to capture scene in an anonymous method // here as we need it later in the callbacks scene.EventManager.OnRegisterCaps += delegate(UUID agentID, Caps caps) - { - OnRegisterCaps(scene, agentID, caps); - }; - - + { + OnRegisterCaps(scene, agentID, caps); + }; + + try { @@ -259,53 +254,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } - + } + } + + public void PostInitialise() + { if (m_pluginEnabled) { m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); - + // register the voice interface for this module, so the script engine can call us m_scene.RegisterModuleInterface(this); } } - public void RegionLoaded(Scene scene) - { - } - - public void RemoveRegion(Scene scene) - { - if (UseProxy) - { - MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/", m_freeSwitchAPIPrefix)); - } - else - { - MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix)); - - MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix)); - - MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix)); - - MainServer.Instance.RemoveHTTPHandler("", String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix)); - } - scene.EventManager.OnRegisterCaps -= delegate(UUID agentID, Caps caps) - { - OnRegisterCaps(scene, agentID, caps); - }; - scene.UnregisterModuleInterface(this); - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public void PostInitialise() - { - } - public void Close() { } @@ -314,6 +277,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { get { return "FreeSwitchVoiceModule"; } } + + public bool IsSharedModule + { + get { return true; } + } // // implementation of IVoiceModule, called by osSetParcelSIPAddress script function -- cgit v1.1 From d1f2fae3481ea502630eaf2c4d1cdb776b165c05 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 20 Feb 2010 11:01:50 +0900 Subject: Formatting cleanup. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 123 +++++++++------------ 1 file changed, 54 insertions(+), 69 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index b04b076..35819a6 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -50,7 +50,6 @@ using OpenSim.Region.Framework.Scenes; using Caps = OpenSim.Framework.Capabilities.Caps; using System.Text.RegularExpressions; - namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule @@ -76,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // SLVoice client will do a GET on this prefix private static string m_freeSwitchAPIPrefix; - // We need to return some information to SLVoice + // We need to return some information to SLVoice // figured those out via curl // http://vd1.vivox.com/api2/viv_get_prelogin.php // @@ -102,9 +101,9 @@ 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; @@ -136,9 +135,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); - + // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) - + string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); int servicePort = m_config.GetInt("freeswitch_service_port", 80); IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); @@ -156,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); - + if (String.IsNullOrEmpty(m_freeSwitchServerUser) || String.IsNullOrEmpty(m_freeSwitchServerPass) || String.IsNullOrEmpty(m_freeSwitchRealm) || @@ -182,9 +181,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); - + // RestStreamHandler h = new - // RestStreamHandler("GET", + // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // MainServer.Instance.AddStreamHandler(h); @@ -202,13 +201,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); } - - - - m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); - + m_FreeSwitchDirectory = new FreeSwitchDirectory(); m_FreeSwitchDialplan = new FreeSwitchDialplan(); @@ -225,7 +220,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } } - if (m_pluginEnabled) + if (m_pluginEnabled) { // we need to capture scene in an anonymous method // here as we need it later in the callbacks @@ -233,8 +228,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { OnRegisterCaps(scene, agentID, caps); }; - - try { @@ -254,16 +247,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } - } } - + public void PostInitialise() { if (m_pluginEnabled) { m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); - + // register the voice interface for this module, so the script engine can call us m_scene.RegisterModuleInterface(this); } @@ -282,15 +274,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { get { return true; } } - + // // implementation of IVoiceModule, called by osSetParcelSIPAddress script function // public void setLandSIPAddress(string SIPAddress,UUID GlobalID) { - m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}", + m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}", GlobalID, SIPAddress); - + lock (m_ParcelAddress) { if (m_ParcelAddress.ContainsKey(GlobalID.ToString())) @@ -303,18 +295,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } } } - + // // OnRegisterCaps is invoked via the scene.EventManager // everytime OpenSim hands out capabilities to a client // (login, region crossing). We contribute two capabilities to // the set of capabilities handed back to the client: // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. - // + // // ProvisionVoiceAccountRequest allows the client to obtain // the voice account credentials for the avatar it is // controlling (e.g., user name, password, etc). - // + // // ParcelVoiceInfoRequest is invoked whenever the client // changes from one region or parcel to another. // @@ -371,7 +363,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { System.Threading.Thread.Sleep(2000); avatar = scene.GetScenePresence(agentID); - + if (avatar == null) return "undef"; } @@ -407,8 +399,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, - String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, - m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); + String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, + m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); @@ -442,7 +434,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string avatarName = avatar.Name; // - check whether we have a region channel in our cache - // - if not: + // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" @@ -451,12 +443,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channelUri; - if (null == scene.LandChannel) + if (null == scene.LandChannel) throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatarName)); - - // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel @@ -493,22 +483,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); - m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", + m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return r; } catch (Exception e) { - m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", + m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", scene.RegionInfo.RegionName, avatarName, e.Message); - m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", + m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.ToString()); return "undef"; } } - /// /// Callback for a client request for ChatSessionRequest /// @@ -550,7 +539,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string fwdresponsestr = ""; int fwdresponsecode = 200; string fwdresponsecontenttype = "text/xml"; - HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress); forwardreq.Method = method; @@ -577,7 +565,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content_type"] = fwdresponsecontenttype; response["str_response_string"] = fwdresponsestr; response["int_response_code"] = fwdresponsecode; - + return response; } @@ -585,11 +573,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) { m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called"); - + Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; response["keepalive"] = false; - + response["str_response_string"] = String.Format( "\r\n" + "\r\n"+ @@ -607,9 +595,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "", m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, m_freeSwitchEchoServer, m_freeSwitchEchoPort, - m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, + m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, m_freeSwitchUrlResetPassword, ""); - + response["int_response_code"] = 200; m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); @@ -624,7 +612,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["content-type"] = "text/xml"; Hashtable requestBody = parseRequestBody((string)request["body"]); - + if (!requestBody.ContainsKey("auth_token")) return response; @@ -632,7 +620,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice //string[] auth_tokenvals = auth_token.Split(':'); //string username = auth_tokenvals[0]; int strcount = 0; - + string[] ids = new string[strcount]; int iter = -1; @@ -648,7 +636,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } StringBuilder resp = new StringBuilder(); resp.Append(""); - + resp.Append(string.Format(@" OK lib_session @@ -678,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice ", ids[i],i,m_freeSwitchRealm,dt)); } - + resp.Append(""); response["str_response_string"] = resp.ToString(); @@ -694,7 +682,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string requestbody = (string)request["body"]; string uri = (string)request["uri"]; string contenttype = (string)request["content-type"]; - + Hashtable requestBody = parseRequestBody((string)request["body"]); //string pwd = (string) requestBody["pwd"]; @@ -712,7 +700,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice pos++; if (s == userid) break; - } } } @@ -735,7 +722,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice ", userid, pos, avatarName); - + response["int_response_code"] = 200; return response; /* @@ -752,13 +739,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) { m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); - + Hashtable response = new Hashtable(); response["str_response_string"] = string.Empty; // all the params come as NVPs in the request body Hashtable requestBody = parseRequestBody((string) request["body"]); - // is this a dialplan or directory request + // is this a dialplan or directory request string section = (string) requestBody["section"]; if (section == "directory") @@ -767,40 +754,39 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); else m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); - - // XXX: re-generate dialplan: + + // XXX: re-generate dialplan: // - conf == region UUID // - conf number = region port // -> TODO Initialise(): keep track of regions via events - // re-generate accounts for all avatars + // re-generate accounts for all avatars // -> TODO Initialise(): keep track of avatars via events Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), "")); return response; } - + public Hashtable parseRequestBody(string body) { Hashtable bodyParams = new Hashtable(); // split string string [] nvps = body.Split(new Char [] {'&'}); - foreach (string s in nvps) { - + foreach (string s in nvps) + { if (s.Trim() != "") { string [] nvp = s.Split(new Char [] {'='}); bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1])); } } - + return bodyParams; } private string ChannelUri(Scene scene, LandData land) { - string channelUri = null; string landUUID; @@ -808,12 +794,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same // as the directory ID. Otherwise, it reflects the parcel's ID. - + lock (m_ParcelAddress) { if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) { - m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", + m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]); return m_ParcelAddress[land.GlobalID.ToString()]; } @@ -823,22 +809,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); landUUID = land.GlobalID.ToString(); - m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", + m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", landName, land.LocalID, landUUID); } else { landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); landUUID = scene.RegionInfo.RegionID.ToString(); - m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", + m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", landName, land.LocalID, landUUID); } System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); - + // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); - + lock (m_ParcelAddress) { if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) @@ -849,14 +835,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return channelUri; } - + private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) { - return true; - } } + public class MonoCert : ICertificatePolicy { #region ICertificatePolicy Members -- cgit v1.1 From e6c52f38c5a8b2c5ee59919942f25b9368bfa41b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 21 Nov 2010 22:25:50 +0000 Subject: Strip the dialplan and directory methods from the region module --- .../Voice/FreeSwitchVoice/FreeSwitchDialplan.cs | 104 ------ .../Voice/FreeSwitchVoice/FreeSwitchDirectory.cs | 348 --------------------- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 80 +---- 3 files changed, 10 insertions(+), 522 deletions(-) delete mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs delete mode 100644 OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs deleted file mode 100644 index 46ad30f..0000000 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDialplan.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using log4net; -using System; -using System.Reflection; -using System.Text; -using System.Collections; - -namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice -{ - public class FreeSwitchDialplan - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - - public Hashtable HandleDialplanRequest(string Context, string Realm, Hashtable request) - { - m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString()); - - Hashtable response = new Hashtable(); - - foreach (DictionaryEntry item in request) - { - m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value); - } - - string requestcontext = (string) request["Hunt-Context"]; - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - if (Context != String.Empty && Context != requestcontext) - { - m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context"); - response["str_response_string"] = ""; - } else { - response["str_response_string"] = String.Format(@" - -
- " + - -/* - - - - - - */ - - @" - - - - - - - - - - - - - - - - - - - - -
-
", Context, Realm); - } - - return response; - } - } - -} diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs deleted file mode 100644 index 17cdf74..0000000 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchDirectory.cs +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using log4net; -using System; -using System.Reflection; -using System.Text; -using System.Collections; - -namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice -{ - public class FreeSwitchDirectory - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public Hashtable HandleDirectoryRequest(string Context, string Realm, Hashtable request) - { - Hashtable response = new Hashtable(); - string domain = (string) request["domain"]; - if (domain != Realm) { - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = ""; - } else { - m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString()); - - // information in the request we might be interested in - - // Request 1 sip_auth for users account - - //Event-Calling-Function=sofia_reg_parse_auth - //Event-Calling-Line-Number=1494 - //action=sip_auth - //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41) - //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) - //sip_auth_realm=9.20.151.43 - //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==) - //sip_contact_host=192.168.0.3 // this shouldnt really be a local IP, investigate STUN servers - //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D - //sip_to_host=9.20.151.43 - //sip_auth_method=REGISTER - //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D - //domain=9.20.151.43 - //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup - - foreach (DictionaryEntry item in request) - { - m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value); - } - - string eventCallingFunction = (string) request["Event-Calling-Function"]; - if (eventCallingFunction == null) - { - eventCallingFunction = "sofia_reg_parse_auth"; - } - - if (eventCallingFunction.Length == 0) - { - eventCallingFunction = "sofia_reg_parse_auth"; - } - - if (eventCallingFunction == "sofia_reg_parse_auth") - { - string sipAuthMethod = (string)request["sip_auth_method"]; - - if (sipAuthMethod == "REGISTER") - { - response = HandleRegister(Context, Realm, request); - } - else if (sipAuthMethod == "INVITE") - { - response = HandleInvite(Context, Realm, request); - } - else - { - m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod); - response["int_response_code"] = 404; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - } - else if (eventCallingFunction == "switch_xml_locate_user") - { - response = HandleLocateUser(Realm, request); - } - else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made - { - response = HandleLocateUser(Realm, request); - } - else if (eventCallingFunction == "user_outgoing_channel") - { - response = HandleRegister(Context, Realm, request); - } - else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup - { - response = HandleConfigSofia(Context, Realm, request); - } - else if (eventCallingFunction == "switch_load_network_lists") - { - //response = HandleLoadNetworkLists(request); - response["int_response_code"] = 404; - response["keepalive"] = false; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - else - { - m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction); - response["int_response_code"] = 404; - response["keepalive"] = false; - response["content_type"] = "text/xml"; - response["str_response_string"] = ""; - } - } - return response; - } - - private Hashtable HandleRegister(string Context, string Realm, Hashtable request) - { - m_log.Info("[FreeSwitchDirectory] HandleRegister called"); - - // TODO the password we return needs to match that sent in the request, this is hard coded for now - string password = "1234"; - string domain = (string) request["domain"]; - string user = (string) request["user"]; - - Hashtable response = new Hashtable(); - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - - response["str_response_string"] = String.Format( - "\r\n" + - "\r\n" + - "
\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - ""+ - "\r\n" + - "\r\n" + - "\r\n" + - "
\r\n" + - "
\r\n", - domain , user, password, Context); - - return response; - } - - private Hashtable HandleInvite(string Context, string Realm, Hashtable request) - { - m_log.Info("[FreeSwitchDirectory] HandleInvite called"); - - // TODO the password we return needs to match that sent in the request, this is hard coded for now - string password = "1234"; - string domain = (string) request["domain"]; - string user = (string) request["user"]; - string sipRequestUser = (string) request["sip_request_user"]; - - Hashtable response = new Hashtable(); - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = String.Format( - "\r\n" + - "\r\n" + - "
\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - ""+ - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - ""+ - "\r\n" + - "\r\n" + - "\r\n" + - "
\r\n" + - "
\r\n", - domain , user, password,sipRequestUser, Context); - - return response; - } - - private Hashtable HandleLocateUser(String Realm, Hashtable request) - { - m_log.Info("[FreeSwitchDirectory] HandleLocateUser called"); - - // TODO the password we return needs to match that sent in the request, this is hard coded for now - string domain = (string) request["domain"]; - string user = (string) request["user"]; - - Hashtable response = new Hashtable(); - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = String.Format( - "\r\n" + - "\r\n" + - "
\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n"+ - "\r\n"+ - ""+ - "\r\n"+ - "\r\n" + - "\r\n" + - "
\r\n" + - "
\r\n", - domain , user); - - return response; - } - - private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request) - { - m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called"); - - // TODO the password we return needs to match that sent in the request, this is hard coded for now - string domain = (string) request["domain"]; - - Hashtable response = new Hashtable(); - response["content_type"] = "text/xml"; - response["keepalive"] = false; - response["int_response_code"] = 200; - response["str_response_string"] = String.Format( - "\r\n" + - "\r\n" + - "
\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n"+ - ""+ - "\r\n" + - "\r\n"+ - "\r\n"+ - "\r\n"+ - "\r\n" + - "
\r\n" + - "
\r\n", - domain, Context); - - return response; - } - - -// private Hashtable HandleLoadNetworkLists(Hashtable request) -// { -// m_log.Info("[FreeSwitchDirectory] HandleLoadNetworkLists called"); -// -// // TODO the password we return needs to match that sent in the request, this is hard coded for now -// string domain = (string) request["domain"]; -// -// Hashtable response = new Hashtable(); -// response["content_type"] = "text/xml"; -// response["keepalive"] = false; -// response["int_response_code"] = 200; -// response["str_response_string"] = String.Format( -// "\r\n" + -// "\r\n" + -// "
\r\n" + -// "\r\n" + -// "\r\n" + -// "\r\n" + -// "\r\n" + -// "\r\n" + -// "\r\n"+ -// "\r\n"+ -// "\r\n"+ -// "\r\n" + -// "
\r\n" + -// "
\r\n", -// domain); -// -// -// return response; -// } - } -} diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 242bc3f..cceaa9b 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -96,9 +96,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private string m_openSimWellKnownHTTPAddress; private string m_freeSwitchContext; - private FreeSwitchDirectory m_FreeSwitchDirectory; - private FreeSwitchDialplan m_FreeSwitchDialplan; - private readonly Dictionary m_UUIDName = new Dictionary(); private Dictionary m_ParcelAddress = new Dictionary(); @@ -172,41 +169,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // - buddies: viv_buddy.php // - ???: viv_watcher.php // - signout: viv_signout.php - if (UseProxy) - { - MainServer.Instance.AddHTTPHandler(String.Format("{0}/", m_freeSwitchAPIPrefix), - ForwardProxyRequest); - } - else - { - MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceGetPreloginHTTPHandler); + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceGetPreloginHTTPHandler); - // RestStreamHandler h = new - // RestStreamHandler("GET", - // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); - // MainServer.Instance.AddStreamHandler(h); + // RestStreamHandler h = new + // RestStreamHandler("GET", + // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); + // MainServer.Instance.AddStreamHandler(h); - MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceSigninHTTPHandler); + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceSigninHTTPHandler); - // set up http request handlers to provide - // on-demand FreeSwitch configuration to - // FreeSwitch's mod_curl_xml - MainServer.Instance.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), - FreeSwitchConfigHTTPHandler); - - MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceBuddyHTTPHandler); - } + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceBuddyHTTPHandler); m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); - m_FreeSwitchDirectory = new FreeSwitchDirectory(); - m_FreeSwitchDialplan = new FreeSwitchDialplan(); - m_pluginEnabled = true; m_WOF = false; @@ -725,46 +705,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["int_response_code"] = 200; return response; - /* - - OKOklib_session - * xMj1QJSc7TA-G7XqcW6QXAg==:1290551700:050d35c6fef96f132f780d8039ff7592:: - * xMj1QJSc7TA-G7XqcW6QXAg==:1290551700:050d35c6fef96f132f780d8039ff7592:: - * 1 - * 7449 - * Teravus Ousley - */ - } - - public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) - { - m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); - - Hashtable response = new Hashtable(); - response["str_response_string"] = string.Empty; - // all the params come as NVPs in the request body - Hashtable requestBody = parseRequestBody((string) request["body"]); - - // is this a dialplan or directory request - string section = (string) requestBody["section"]; - - if (section == "directory") - response = m_FreeSwitchDirectory.HandleDirectoryRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); - else if (section == "dialplan") - response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); - else - m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); - - // XXX: re-generate dialplan: - // - conf == region UUID - // - conf number = region port - // -> TODO Initialise(): keep track of regions via events - // re-generate accounts for all avatars - // -> TODO Initialise(): keep track of avatars via events - Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); - - m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), "")); - return response; } public Hashtable parseRequestBody(string body) -- cgit v1.1 From 6fa24f46712b7e266f6d5dfc55f395f2c489671c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 21 Nov 2010 22:40:03 +0000 Subject: Convert the Freeswitch module to new style --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 191 +++++++++++---------- 1 file changed, 98 insertions(+), 93 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index cceaa9b..4095674 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -41,6 +41,7 @@ using log4net; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; +using Mono.Addins; using OpenSim.Framework.Capabilities; using OpenSim.Framework.Servers; @@ -52,7 +53,8 @@ using System.Text.RegularExpressions; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { - public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FreeSwitchVoiceModule")] + public class FreeSwitchVoiceModule : INonSharedRegionModule, IVoiceModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -64,8 +66,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static readonly string m_chatSessionRequestPath = "0009/"; // Control info - private static bool m_WOF = true; - private static bool m_pluginEnabled = false; + private static bool m_Enabled = false; // FreeSwitch server is going to contact us and ask us all // sorts of things. @@ -104,9 +105,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private IConfig m_config; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - m_scene = scene; m_config = config.Configs["FreeSwitchVoice"]; if (null == m_config) @@ -121,86 +121,106 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return; } - // This is only done the FIRST time this method is invoked. - if (m_WOF) - { - m_pluginEnabled = true; - m_WOF = false; + m_Enabled = true; - try + try + { + m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); + m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); + m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); + + // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) + + string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); + int servicePort = m_config.GetInt("freeswitch_service_port", 80); + IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); + // m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); + m_freeSwitchServicePort = servicePort; + m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); + m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); + m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); + // m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); + m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); + m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); + m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); + m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString()); + m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); + // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); + m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); + m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); + + if (String.IsNullOrEmpty(m_freeSwitchServerUser) || + String.IsNullOrEmpty(m_freeSwitchServerPass) || + String.IsNullOrEmpty(m_freeSwitchRealm) || + String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) { - m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); - m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); - m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); - - // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) - - string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); - int servicePort = m_config.GetInt("freeswitch_service_port", 80); - IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); - // m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); - m_freeSwitchServicePort = servicePort; - m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); - m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); - m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); - // m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); - m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); - m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); - m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); - m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString()); - m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); - // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); - m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); - m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); - - if (String.IsNullOrEmpty(m_freeSwitchServerUser) || - String.IsNullOrEmpty(m_freeSwitchServerPass) || - String.IsNullOrEmpty(m_freeSwitchRealm) || - String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) - { - m_log.Error("[FreeSwitchVoice] plugin mis-configured"); - m_log.Info("[FreeSwitchVoice] plugin disabled: incomplete configuration"); - return; - } + m_log.Error("[FreeSwitchVoice] plugin mis-configured"); + m_log.Info("[FreeSwitchVoice] plugin disabled: incomplete configuration"); + return; + } - // set up http request handlers for - // - prelogin: viv_get_prelogin.php - // - signin: viv_signin.php - // - buddies: viv_buddy.php - // - ???: viv_watcher.php - // - signout: viv_signout.php - MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceGetPreloginHTTPHandler); + // set up http request handlers for + // - prelogin: viv_get_prelogin.php + // - signin: viv_signin.php + // - buddies: viv_buddy.php + // - ???: viv_watcher.php + // - signout: viv_signout.php + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceGetPreloginHTTPHandler); - // RestStreamHandler h = new - // RestStreamHandler("GET", - // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); - // MainServer.Instance.AddStreamHandler(h); + // RestStreamHandler h = new + // RestStreamHandler("GET", + // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); + // MainServer.Instance.AddStreamHandler(h); - MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceSigninHTTPHandler); + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceSigninHTTPHandler); - MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), - FreeSwitchSLVoiceBuddyHTTPHandler); + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceBuddyHTTPHandler); - m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); + m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); - m_pluginEnabled = true; - m_WOF = false; + m_Enabled = true; + + m_log.Info("[FreeSwitchVoice] plugin enabled"); + } + catch (Exception e) + { + m_log.ErrorFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); + m_log.DebugFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString()); + return; + } - m_log.Info("[FreeSwitchVoice] plugin enabled"); + // This here is a region module trying to make a global setting. + // Not really a good idea but it's Windows only, so I can't test. + try + { + ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; + } + catch (NotImplementedException) + { + try + { +#pragma warning disable 0612, 0618 + // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! + ServicePointManager.CertificatePolicy = new MonoCert(); +#pragma warning restore 0612, 0618 } - catch (Exception e) + catch (Exception) { - m_log.ErrorFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); - m_log.DebugFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString()); - return; + //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } + } + + public void AddRegion(Scene scene) + { + m_scene = scene; - if (m_pluginEnabled) + if (m_Enabled) { // we need to capture scene in an anonymous method // here as we need it later in the callbacks @@ -208,36 +228,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { OnRegisterCaps(scene, agentID, caps); }; - - try - { - ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; - } - catch (NotImplementedException) - { - try - { -#pragma warning disable 0612, 0618 - // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! - ServicePointManager.CertificatePolicy = new MonoCert(); -#pragma warning restore 0612, 0618 - } - catch (Exception) - { - m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); - } - } } } - public void PostInitialise() + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) { - if (m_pluginEnabled) + if (m_Enabled) { m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); // register the voice interface for this module, so the script engine can call us - m_scene.RegisterModuleInterface(this); + scene.RegisterModuleInterface(this); } } @@ -250,9 +255,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice get { return "FreeSwitchVoiceModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } // -- cgit v1.1 From 21058425133dff8499f856a32af29547f537445a Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 21 Nov 2010 23:24:39 +0000 Subject: Finish the standalone mode freeswitch work and add config examples --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 90 +++++++++++----------- 1 file changed, 47 insertions(+), 43 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 4095674..a5e553c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -37,6 +37,7 @@ using System.Collections; using System.Collections.Generic; using System.Reflection; using OpenMetaverse; +using OpenMetaverse.StructuredData; using log4net; using Nini.Config; using Nwc.XmlRpc; @@ -50,6 +51,9 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Caps = OpenSim.Framework.Capabilities.Caps; using System.Text.RegularExpressions; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { @@ -58,8 +62,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private bool UseProxy = false; - // Capability string prefixes private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; @@ -70,8 +72,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // FreeSwitch server is going to contact us and ask us all // sorts of things. - private static string m_freeSwitchServerUser; - private static string m_freeSwitchServerPass; // SLVoice client will do a GET on this prefix private static string m_freeSwitchAPIPrefix; @@ -85,73 +85,69 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static string m_freeSwitchRealm; private static string m_freeSwitchSIPProxy; private static bool m_freeSwitchAttemptUseSTUN; - // private static string m_freeSwitchSTUNServer; private static string m_freeSwitchEchoServer; private static int m_freeSwitchEchoPort; private static string m_freeSwitchDefaultWellKnownIP; private static int m_freeSwitchDefaultTimeout; - // private static int m_freeSwitchSubscribeRetry; private static string m_freeSwitchUrlResetPassword; - // private static IPEndPoint m_FreeSwitchServiceIP; - private int m_freeSwitchServicePort; + private uint m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; private string m_freeSwitchContext; private readonly Dictionary m_UUIDName = new Dictionary(); private Dictionary m_ParcelAddress = new Dictionary(); - private Scene m_scene; + private Scene m_Scene; + private IConfig m_Config; - private IConfig m_config; + private IFreeswitchService m_FreeswitchService; public void Initialise(IConfigSource config) { - m_config = config.Configs["FreeSwitchVoice"]; + m_Config = config.Configs["FreeSwitchVoice"]; - if (null == m_config) + if (m_Config == null) { m_log.Info("[FreeSwitchVoice] no config found, plugin disabled"); return; } - if (!m_config.GetBoolean("enabled", false)) + if (!m_Config.GetBoolean("Enabled", false)) { m_log.Info("[FreeSwitchVoice] plugin disabled by configuration"); return; } - m_Enabled = true; - try { - m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); - m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); - m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); - - // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) - - string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); - int servicePort = m_config.GetInt("freeswitch_service_port", 80); - IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); - // m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); - m_freeSwitchServicePort = servicePort; - m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); - m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); - m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); - // m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); - m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); - m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); - m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); - m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString()); - m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); - // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); - m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); - m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); - - if (String.IsNullOrEmpty(m_freeSwitchServerUser) || - String.IsNullOrEmpty(m_freeSwitchServerPass) || - String.IsNullOrEmpty(m_freeSwitchRealm) || + string serviceDll = m_Config.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[FreeSwitchVoice]: No LocalServiceModule named in section FreeSwitchVoice"); + return; + } + + Object[] args = new Object[] { config }; + m_FreeswitchService = ServerUtils.LoadPlugin(serviceDll, args); + + string jsonConfig = m_FreeswitchService.GetJsonConfig(); + OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); + + m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); + m_freeSwitchRealm = map["Realm"].AsString(); + m_freeSwitchSIPProxy = map["SIPProxy"].AsString(); + m_freeSwitchAttemptUseSTUN = map["AttemptUseSTUN"].AsBoolean(); + m_freeSwitchEchoServer = map["EchoServer"].AsString(); + m_freeSwitchEchoPort = map["EchoPort"].AsInteger(); + m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); + m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); + m_freeSwitchUrlResetPassword = String.Empty; + m_freeSwitchContext = map["Context"].AsString(); + + if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) { m_log.Error("[FreeSwitchVoice] plugin mis-configured"); @@ -211,6 +207,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } catch (Exception) { + // COmmented multiline spam log message //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } @@ -218,7 +215,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public void AddRegion(Scene scene) { - m_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_freeSwitchServicePort = MainServer.Instance.Port; if (m_Enabled) { -- cgit v1.1 From ddf08276f1c01f3d5f85ee3077062ca5d6a8a812 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Nov 2010 00:55:11 +0100 Subject: Fox the buglets in Freeswitch. Grid mode works now and there is no reason why standalone should not. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index a5e553c..294d4f0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -134,6 +134,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_FreeswitchService = ServerUtils.LoadPlugin(serviceDll, args); string jsonConfig = m_FreeswitchService.GetJsonConfig(); + m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); -- cgit v1.1 From 4e0a289a8dfc069201a856d2a67510c5b6b91ccf Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Nov 2010 14:13:27 +0000 Subject: 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. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 294d4f0..9a17233 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 AddRegion(Scene scene) + public void PostInitialise() { - m_Scene = scene; + } + public void AddRegion(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 -- cgit v1.1 From d2aebbe0669481c9f416c78dd40ca6007da09f02 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Nov 2010 14:32:51 +0100 Subject: Fox case on a method --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 9a17233..a583cca 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -603,7 +603,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["str_response_string"] = string.Empty; response["content-type"] = "text/xml"; - Hashtable requestBody = parseRequestBody((string)request["body"]); + Hashtable requestBody = ParseRequestBody((string)request["body"]); if (!requestBody.ContainsKey("auth_token")) return response; @@ -675,7 +675,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string uri = (string)request["uri"]; string contenttype = (string)request["content-type"]; - Hashtable requestBody = parseRequestBody((string)request["body"]); + Hashtable requestBody = ParseRequestBody((string)request["body"]); //string pwd = (string) requestBody["pwd"]; string userid = (string) requestBody["userid"]; @@ -719,7 +719,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } - public Hashtable parseRequestBody(string body) + public Hashtable ParseRequestBody(string body) { Hashtable bodyParams = new Hashtable(); // split string -- cgit v1.1 From 5aeb83125a9485eb0ab38c65a939964973b7962b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Nov 2010 23:30:55 +0000 Subject: Remove the most spammy XML dumps from the FS voice module --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index a583cca..0b51bf0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -132,7 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_FreeswitchService = ServerUtils.LoadPlugin(serviceDll, args); string jsonConfig = m_FreeswitchService.GetJsonConfig(); - m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); + //m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); @@ -363,7 +363,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice try { - m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", + //m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); //XmlElement resp; @@ -445,7 +445,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // voice channel LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); - m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", + //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // TODO: EstateSettings don't seem to get propagated... @@ -592,7 +592,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["int_response_code"] = 200; - m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); + //m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); return response; } @@ -664,7 +664,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["str_response_string"] = resp.ToString(); Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); - m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); + //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); return response; } @@ -696,7 +696,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } } - m_log.DebugFormat("[FreeSwitchVoice]: AUTH, URI: {0}, Content-Type:{1}, Body{2}", uri, contenttype, + //m_log.DebugFormat("[FreeSwitchVoice]: AUTH, URI: {0}, Content-Type:{1}, Body{2}", uri, contenttype, requestbody); Hashtable response = new Hashtable(); response["str_response_string"] = string.Format(@" -- cgit v1.1 From 04ce7de5ed54b0586c3287b6c848dadfb507b132 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 29 Nov 2010 01:15:02 +0000 Subject: Fix the build break --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 0b51bf0..e9c5453 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -364,7 +364,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice try { //m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", - request, path, param); + // request, path, param); //XmlElement resp; string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); @@ -446,7 +446,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", - scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); + // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // TODO: EstateSettings don't seem to get propagated... // if (!scene.RegionInfo.EstateSettings.AllowVoice) @@ -697,7 +697,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice } //m_log.DebugFormat("[FreeSwitchVoice]: AUTH, URI: {0}, Content-Type:{1}, Body{2}", uri, contenttype, - requestbody); + // requestbody); Hashtable response = new Hashtable(); response["str_response_string"] = string.Format(@" -- cgit v1.1 From 8efb01b3df1ea98d5e4a68aa220bafc4ab5306f4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 5 Mar 2011 01:15:27 +0000 Subject: minor: remove some mono compiler warnings --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index e9c5453..05a1c3b 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static string m_freeSwitchUrlResetPassword; private uint m_freeSwitchServicePort; private string m_openSimWellKnownHTTPAddress; - private string m_freeSwitchContext; +// private string m_freeSwitchContext; private readonly Dictionary m_UUIDName = new Dictionary(); private Dictionary m_ParcelAddress = new Dictionary(); @@ -144,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); m_freeSwitchUrlResetPassword = String.Empty; - m_freeSwitchContext = map["Context"].AsString(); +// m_freeSwitchContext = map["Context"].AsString(); if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) @@ -662,7 +662,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice resp.Append(""); response["str_response_string"] = resp.ToString(); - Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); +// Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); return response; @@ -671,9 +671,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) { m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); - string requestbody = (string)request["body"]; - string uri = (string)request["uri"]; - string contenttype = (string)request["content-type"]; +// string requestbody = (string)request["body"]; +// string uri = (string)request["uri"]; +// string contenttype = (string)request["content-type"]; Hashtable requestBody = ParseRequestBody((string)request["body"]); -- cgit v1.1 From 4f56c732bc00588cd8ced1be85bc4d13815f86bd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 02:29:42 +0100 Subject: Comment out some startup logging lines to make up for the one I added earlier on. Most of these are where the region modules are telling us they are disabled. Convention is only to log when enabled (even that is really noisy) --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 ------ .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 8 -------- 2 files changed, 14 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 05a1c3b..7909d8a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -106,16 +106,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_Config = config.Configs["FreeSwitchVoice"]; if (m_Config == null) - { - m_log.Info("[FreeSwitchVoice] no config found, plugin disabled"); return; - } if (!m_Config.GetBoolean("Enabled", false)) - { - m_log.Info("[FreeSwitchVoice] plugin disabled by configuration"); return; - } try { diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 34d0e24..534bf92 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -121,16 +121,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice m_config = config.Configs["VivoxVoice"]; if (null == m_config) - { - m_log.Info("[VivoxVoice] no config found, plugin disabled"); return; - } if (!m_config.GetBoolean("enabled", false)) - { - m_log.Info("[VivoxVoice] plugin disabled by configuration"); return; - } try { @@ -218,7 +212,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice m_pluginEnabled = true; m_log.Info("[VivoxVoice] plugin enabled"); - } catch (Exception e) { @@ -228,7 +221,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice } } - // Called to indicate that the module has been added to the region public void AddRegion(Scene scene) { -- cgit v1.1 From 2fa210243b64bb10fbca37f89176f10efeb25f41 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 19 Apr 2011 21:54:26 +0100 Subject: Clean up freeswitch config to what is currently required. Add explanation to config parameters. Clean up some log messages. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 7909d8a..962b5ca 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if (serviceDll == String.Empty) { - m_log.Error("[FreeSwitchVoice]: No LocalServiceModule named in section FreeSwitchVoice"); + m_log.Error("[FreeSwitchVoice]: No LocalServiceModule named in section FreeSwitchVoice. Not starting."); return; } @@ -143,8 +143,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) { - m_log.Error("[FreeSwitchVoice] plugin mis-configured"); - m_log.Info("[FreeSwitchVoice] plugin disabled: incomplete configuration"); + m_log.Error("[FreeSwitchVoice]: Freeswitch service mis-configured. Not starting."); return; } @@ -172,16 +171,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); - m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); + m_log.InfoFormat("[FreeSwitchVoice]: using FreeSwitch server {0}", m_freeSwitchRealm); m_Enabled = true; - m_log.Info("[FreeSwitchVoice] plugin enabled"); + m_log.Info("[FreeSwitchVoice]: plugin enabled"); } catch (Exception e) { - m_log.ErrorFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); - m_log.DebugFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString()); + m_log.ErrorFormat("[FreeSwitchVoice]: plugin initialization failed: {0} {1}", e.Message, e.StackTrace); return; } @@ -240,7 +238,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice { if (m_Enabled) { - m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); + m_log.Info("[FreeSwitchVoice]: registering IVoiceModule with the scene"); // register the voice interface for this module, so the script engine can call us scene.RegisterModuleInterface(this); @@ -302,7 +300,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps) { - m_log.DebugFormat("[FreeSwitchVoice] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); + m_log.DebugFormat( + "[FreeSwitchVoice]: OnRegisterCaps called with agentID {0} caps {1} in scene {2}", + agentID, caps, scene.RegionInfo.RegionName); string capsBase = "/CAPS/" + caps.CapsObjectPath; caps.RegisterHandler("ProvisionVoiceAccountRequest", @@ -558,7 +558,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) { - m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called"); + m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceGetPreloginHTTPHandler called"); Hashtable response = new Hashtable(); response["content_type"] = "text/xml"; @@ -664,7 +664,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) { - m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); + m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceSigninHTTPHandler called"); // string requestbody = (string)request["body"]; // string uri = (string)request["uri"]; // string contenttype = (string)request["content-type"]; @@ -795,16 +795,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice response["keepalive"] = false; response["int_response_code"] = 500; - Hashtable requestBody = ParseRequestBody((string) request["body"]); + Hashtable requestBody = ParseRequestBody((string)request["body"]); string section = (string) requestBody["section"]; + + m_log.DebugFormat("[FreeSwitchVoice]: Received request for config section {0}", 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); + m_log.WarnFormat("[FreeSwitchVoice]: Unknown section {0} was requested.", section); return response; } -- cgit v1.1 From ccc26f74436f0e3069587efd96497053e4129c3c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 20 Apr 2011 01:02:40 +0100 Subject: Get Viewer 2 voice working with OpenSim. See http://opensimulator.org/mantis/view.php?id=5336 It turns out that viewer 2 was upset by the lack of a response to viv_watcher.php. This would send it into a continuous login loop. Viewer 1 was quite happy to ignore the lack of response. This commit puts in the bare minimum 'OK' message in response to viv_watcher.php. This allows viewer 2 voice to connect and appears to work. However, at some point we need to fill out the watcher response, whatever that is. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 79 ++++++++++++++++++---- 1 file changed, 66 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 962b5ca..373ffeb 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -163,13 +163,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // MainServer.Instance.AddStreamHandler(h); - - MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); + + MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_watcher.php", m_freeSwitchAPIPrefix), + FreeSwitchSLVoiceWatcherHTTPHandler); m_log.InfoFormat("[FreeSwitchVoice]: using FreeSwitch server {0}", m_freeSwitchRealm); @@ -301,7 +302,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps) { m_log.DebugFormat( - "[FreeSwitchVoice]: OnRegisterCaps called with agentID {0} caps {1} in scene {2}", + "[FreeSwitchVoice]: OnRegisterCaps() called with agentID {0} caps {1} in scene {2}", agentID, caps, scene.RegionInfo.RegionName); string capsBase = "/CAPS/" + caps.CapsObjectPath; @@ -344,6 +345,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { + m_log.DebugFormat( + "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request: {0}, path: {1}, param: {2}", request, path, param); + ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) { @@ -357,9 +361,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice try { - //m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", - // request, path, param); - //XmlElement resp; string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string password = "1234";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); @@ -416,6 +417,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { +// m_log.DebugFormat( +// "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() on {0} for {1}", +// scene.RegionInfo.RegionName, agentID); + ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; @@ -502,6 +507,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.DebugFormat("[FreeSwitchVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", avatarName, request, path, param); + return "true"; } @@ -555,7 +561,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice return response; } - public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) { m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceGetPreloginHTTPHandler called"); @@ -592,6 +597,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public Hashtable FreeSwitchSLVoiceBuddyHTTPHandler(Hashtable request) { + m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceBuddyHTTPHandler called"); + Hashtable response = new Hashtable(); response["int_response_code"] = 200; response["str_response_string"] = string.Empty; @@ -650,18 +657,61 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice A {3} - ", ids[i],i,m_freeSwitchRealm,dt)); + ", ids[i], i ,m_freeSwitchRealm, dt)); } resp.Append(""); response["str_response_string"] = resp.ToString(); -// Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); - - //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); +// Regex normalizeEndLines = new Regex(@"(\r\n|\n)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); +// +// m_log.DebugFormat( +// "[FREESWITCH]: FreeSwitchSLVoiceBuddyHTTPHandler() response {0}", +// normalizeEndLines.Replace((string)response["str_response_string"],"")); + return response; } + public Hashtable FreeSwitchSLVoiceWatcherHTTPHandler(Hashtable request) + { + m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceWatcherHTTPHandler called"); + + Hashtable response = new Hashtable(); + response["int_response_code"] = 200; + response["content-type"] = "text/xml"; + + Hashtable requestBody = ParseRequestBody((string)request["body"]); + + string auth_token = (string)requestBody["auth_token"]; + //string[] auth_tokenvals = auth_token.Split(':'); + //string username = auth_tokenvals[0]; + + StringBuilder resp = new StringBuilder(); + resp.Append(""); + + // FIXME: This is enough of a response to stop viewer 2 complaining about a login failure and get voice to work. If we don't + // give an OK response, then viewer 2 engages in an continuous viv_signin.php, viv_buddy.php, viv_watcher.php loop + // Viewer 1 appeared happy to ignore the lack of reply and still works with this reply. + // + // However, really we need to fill in whatever watcher data should be here (whatever that is). + resp.Append(string.Format(@" + OK + lib_session + {0} + {0} + ", auth_token)); + + response["str_response_string"] = resp.ToString(); + +// Regex normalizeEndLines = new Regex(@"(\r\n|\n)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); +// +// m_log.DebugFormat( +// "[FREESWITCH]: FreeSwitchSLVoiceWatcherHTTPHandler() response {0}", +// normalizeEndLines.Replace((string)response["str_response_string"],"")); + + return response; + } + public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) { m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceSigninHTTPHandler called"); @@ -709,7 +759,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice ", userid, pos, avatarName); - response["int_response_code"] = 200; + response["int_response_code"] = 200; + +// m_log.DebugFormat("[FreeSwitchVoice]: Sending FreeSwitchSLVoiceSigninHTTPHandler response"); + return response; } @@ -823,4 +876,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice #endregion } -} +} \ No newline at end of file -- cgit v1.1 From 60685c35179c74c5714abdb0c17611fb59d52c10 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 21 Apr 2011 19:17:38 +0100 Subject: Adjust freeswitch logging to be somewhat less noisy. However, there is still quite a large amount of logging present for debug purposes. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 373ffeb..42efd67 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -391,7 +391,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); - m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); +// m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); return r; } @@ -458,8 +458,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { - m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", - scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); +// m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", +// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channelUri = String.Empty; } else @@ -474,8 +474,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); - m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", - scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); +// m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", +// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return r; } catch (Exception e) @@ -850,16 +850,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice Hashtable requestBody = ParseRequestBody((string)request["body"]); - string section = (string) requestBody["section"]; - - m_log.DebugFormat("[FreeSwitchVoice]: Received request for config section {0}", section); + string section = (string) requestBody["section"]; if (section == "directory") + { + string eventCallingFunction = (string)requestBody["Event-Calling-Function"]; + m_log.DebugFormat( + "[FreeSwitchVoice]: Received request for config section directory, event calling function '{0}'", + eventCallingFunction); + response = m_FreeswitchService.HandleDirectoryRequest(requestBody); + } else if (section == "dialplan") + { + m_log.DebugFormat("[FreeSwitchVoice]: Received request for config section dialplan"); + response = m_FreeswitchService.HandleDialplanRequest(requestBody); + } else - m_log.WarnFormat("[FreeSwitchVoice]: Unknown section {0} was requested.", section); + m_log.WarnFormat("[FreeSwitchVoice]: Unknown section {0} was requested from config.", section); return response; } -- cgit v1.1 From de20f0603fa419ba16c56d16c2ad55301cad8b83 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 24 Jun 2011 19:49:05 +0100 Subject: Tell hypergridders when their teleports fail because of the 4096 limit rather than just saying "destination not found" Instead of performing the 4096 check when the region is linked (and subsequently removing the link), leave the link in place and perform the check in the entity transfer module This allows us to explicitly tell the hypergridder why the teleport failed (region out of range). It also allows people on regions that are within range (on a large source grid) to teleport. The Check4096 config parameter in the [GridService] section is replaced by a max_distance paramter in a new [EntityTransfer] section in OpenSimDefaults.ini Since the parameter is in OpenSimDefaults.ini no action needs to be taken unless you want to increase this limit. It could also be decreased. The check is being made in the base entity transfer module, since I believe the viewer problem occurs both on extremely large grids and while hypergridding. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 42efd67..a5bba4f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -417,9 +417,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { -// m_log.DebugFormat( -// "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() on {0} for {1}", -// scene.RegionInfo.RegionName, agentID); + m_log.DebugFormat( + "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() on {0} for {1}", + scene.RegionInfo.RegionName, agentID); ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; @@ -885,4 +885,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice #endregion } -} \ No newline at end of file +} -- cgit v1.1 From 4567555c49cb560dd6f109bbfec42086af3de56f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Dec 2011 20:44:20 +0000 Subject: Implement IOSHttpRequest and IOSHttpResponse http interfaces and use instead of OSHttpRequest/OSHttpResponse. This is required for the substitution of different HTTP servers or the newer HttpServer.dll without having to commit to a particular implementation. This is also required to write regression tests that involve the HTTP layer. If you need to recompile, all you need to do is replace OSHttpRequest/OSHttpResponse references with IOSHttpRequest/IOSHttpResponse. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 +++--- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index a5bba4f..5323a95 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -309,7 +309,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice caps.RegisterHandler("ProvisionVoiceAccountRequest", new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps); @@ -317,7 +317,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice caps.RegisterHandler("ParcelVoiceInfoRequest", new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps); @@ -325,7 +325,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice caps.RegisterHandler("ChatSessionRequest", new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ChatSessionRequest(scene, request, path, param, agentID, caps); diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 534bf92..70e2f7e 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -421,7 +421,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice caps.RegisterHandler("ProvisionVoiceAccountRequest", new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps); @@ -429,7 +429,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice caps.RegisterHandler("ParcelVoiceInfoRequest", new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps); @@ -437,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice caps.RegisterHandler("ChatSessionRequest", new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ChatSessionRequest(scene, request, path, param, agentID, caps); -- cgit v1.1 From 4589ce61bc68311d6ab7b5e7aa40ed1def40f52e Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Sat, 11 Feb 2012 19:00:01 +0100 Subject: Fix: get embedded objects from Notecard fails with activated FreeSwitchVoiceModul http://opensimulator.org/mantis/view.php?id=2607 --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 5323a95..05678c0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -63,9 +63,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // Capability string prefixes - private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; - private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; - private static readonly string m_chatSessionRequestPath = "0009/"; + private static readonly string m_parcelVoiceInfoRequestPath = "0207/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0208/"; + private static readonly string m_chatSessionRequestPath = "0209/"; // Control info private static bool m_Enabled = false; -- cgit v1.1 From b74a89bc125a9f3c0c7aac0001a84df4ec28a192 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 27 Mar 2012 22:33:42 +0100 Subject: minor: clean up some code formatting in VivoxVoiceModule.cs --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 79 +++++++--------------- 1 file changed, 25 insertions(+), 54 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 70e2f7e..738133c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -221,15 +221,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice } } - // Called to indicate that the module has been added to the region public void AddRegion(Scene scene) { - if (m_pluginEnabled) { lock (vlock) { - string channelId; string sceneUUID = scene.RegionInfo.RegionID.ToString(); @@ -273,23 +270,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice } } - // Create a dictionary entry unconditionally. This eliminates the // need to check for a parent in the core code. The end result is // the same, if the parent table entry is an empty string, then // region channels will be created as first-level channels. - - lock (m_parents) - if (m_parents.ContainsKey(sceneUUID)) - { - RemoveRegion(scene); - m_parents.Add(sceneUUID, channelId); - } - else - { - m_parents.Add(sceneUUID, channelId); - } - + lock (m_parents) + { + if (m_parents.ContainsKey(sceneUUID)) + { + RemoveRegion(scene); + m_parents.Add(sceneUUID, channelId); + } + else + { + m_parents.Add(sceneUUID, channelId); + } + } } // we need to capture scene in an anonymous method @@ -298,26 +294,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice { OnRegisterCaps(scene, agentID, caps); }; - } - } - - // Called to indicate that all loadable modules have now been added + public void RegionLoaded(Scene scene) { // Do nothing. } - // Called to indicate that the region is going away. public void RemoveRegion(Scene scene) { - if (m_pluginEnabled) { lock (vlock) { - string channelId; string sceneUUID = scene.RegionInfo.RegionID.ToString(); @@ -328,10 +318,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // iteration over the set of chidren identified. // This assumes that there is just one directory per // region. - if (VivoxTryGetDirectory(sceneUUID + "D", out channelId)) { - m_log.DebugFormat("[VivoxVoice]: region {0}: uuid {1}: located directory id {2}", sceneName, sceneUUID, channelId); @@ -360,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice lock (m_parents) { - if (m_parents.ContainsKey(sceneUUID)) + if (m_parents.ContainsKey(sceneUUID)) { m_parents.Remove(sceneUUID); } @@ -459,11 +447,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice { try { - ScenePresence avatar = null; string avatarName = null; - if (scene == null) throw new Exception("[VivoxVoice][PROVISIONVOICE] Invalid scene"); + if (scene == null) + throw new Exception("[VivoxVoice][PROVISIONVOICE]: Invalid scene"); avatar = scene.GetScenePresence(agentID); while (avatar == null) @@ -566,7 +554,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice } } } - } while (retry); + } + while (retry); if (code != "OK") { @@ -676,7 +665,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice } } - /// /// Callback for a client request for a private chat channel /// @@ -698,10 +686,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return "true"; } - private string RegionGetOrCreateChannel(Scene scene, LandData land) { - string channelUri = null; string channelId = null; @@ -709,11 +695,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice string landName; string parentId; - lock (m_parents) parentId = m_parents[scene.RegionInfo.RegionID.ToString()]; + lock (m_parents) + parentId = m_parents[scene.RegionInfo.RegionID.ToString()]; // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same // as the directory ID. Otherwise, it reflects the parcel's ID. - if (land.LocalID != 1 && (land.Flags & (uint)ParcelFlags.UseEstateVoiceChan) == 0) { landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); @@ -741,14 +727,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parent channel id {1}: retrieved parcel channel_uri {2} ", landName, parentId, channelUri); - - } return channelUri; } - private static readonly string m_vivoxLoginPath = "http://{0}/api2/viv_signin.php?userid={1}&pwd={2}"; /// @@ -761,7 +744,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return VivoxCall(requrl, false); } - private static readonly string m_vivoxLogoutPath = "http://{0}/api2/viv_signout.php?auth_token={1}"; /// @@ -773,7 +755,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return VivoxCall(requrl, false); } - private static readonly string m_vivoxGetAccountPath = "http://{0}/api2/viv_get_acct.php?auth_token={1}&user_name={2}"; /// @@ -786,7 +767,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return VivoxCall(requrl, true); } - private static readonly string m_vivoxNewAccountPath = "http://{0}/api2/viv_adm_acct_new.php?username={1}&pwd={2}&auth_token={3}"; /// @@ -801,7 +781,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return VivoxCall(requrl, true); } - private static readonly string m_vivoxPasswordPath = "http://{0}/api2/viv_adm_password.php?user_name={1}&new_pwd={2}&auth_token={3}"; /// @@ -813,7 +792,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return VivoxCall(requrl, true); } - private static readonly string m_vivoxChannelPath = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_name={2}&auth_token={3}"; /// @@ -828,7 +806,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice /// /// In this case the call handles parent and description as optional values. /// - private bool VivoxTryCreateChannel(string parent, string channelId, string description, out string channelUri) { string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", channelId, m_authToken); @@ -864,7 +841,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice /// channel name space. /// The parent and description are optional values. /// - private bool VivoxTryCreateDirectory(string dirId, string description, out string channelId) { string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", dirId, m_authToken); @@ -901,7 +877,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice /// are required in a later phase. /// In this case the call handles parent and description as optional values. /// - private bool VivoxTryGetChannel(string channelParent, string channelName, out string channelId, out string channelUri) { @@ -1044,6 +1019,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // return VivoxCall(requrl, true); // } + private static readonly string m_vivoxChannelDel = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_id={2}&auth_token={3}"; + /// /// Delete a channel. /// Once again, there a multitude of options possible. In the simplest case @@ -1055,9 +1032,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice /// are required in a later phase. /// In this case the call handles parent and description as optional values. /// - - private static readonly string m_vivoxChannelDel = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_id={2}&auth_token={3}"; - private XmlElement VivoxDeleteChannel(string parent, string channelid) { string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken); @@ -1068,12 +1042,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return VivoxCall(requrl, true); } + private static readonly string m_vivoxChannelSearch = "http://{0}/api2/viv_chan_search.php?&cond_chanparent={1}&auth_token={2}"; + /// /// Return information on channels in the given directory /// - - private static readonly string m_vivoxChannelSearch = "http://{0}/api2/viv_chan_search.php?&cond_chanparent={1}&auth_token={2}"; - private XmlElement VivoxListChildren(string channelid) { string requrl = String.Format(m_vivoxChannelSearch, m_vivoxServer, channelid, m_authToken); @@ -1118,7 +1091,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice /// The outcome of the call can be determined by examining the /// status value in the hash table. /// - private XmlElement VivoxCall(string requrl, bool admin) { @@ -1164,7 +1136,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice /// /// Just say if it worked. /// - private bool IsOK(XmlElement resp) { string status; @@ -1337,4 +1308,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return false; } } -} +} \ No newline at end of file -- cgit v1.1 From 231a3bf147315a9284140476d2b09e13c3fee1c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 May 2012 01:45:49 +0100 Subject: Implement optional name and description on http stream handlers so that we can relate a slow request to what the handler actually does and the agent it serves, if applicable. This is most useful for capabilities where the url is not self-describing. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 53 +++++++++++---------- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 54 ++++++++++++---------- 2 files changed, 59 insertions(+), 48 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 05678c0..be8873d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -306,30 +306,35 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice agentID, caps, scene.RegionInfo.RegionName); string capsBase = "/CAPS/" + caps.CapsObjectPath; - caps.RegisterHandler("ProvisionVoiceAccountRequest", - new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, - delegate(string request, string path, string param, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - return ProvisionVoiceAccountRequest(scene, request, path, param, - agentID, caps); - })); - caps.RegisterHandler("ParcelVoiceInfoRequest", - new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, - delegate(string request, string path, string param, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - return ParcelVoiceInfoRequest(scene, request, path, param, - agentID, caps); - })); - caps.RegisterHandler("ChatSessionRequest", - new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, - delegate(string request, string path, string param, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - return ChatSessionRequest(scene, request, path, param, - agentID, caps); - })); + caps.RegisterHandler( + "ProvisionVoiceAccountRequest", + new RestStreamHandler( + "POST", + capsBase + m_provisionVoiceAccountRequestPath, + (request, path, param, httpRequest, httpResponse) + => ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps), + "ProvisionVoiceAccountRequest", + agentID.ToString())); + + caps.RegisterHandler( + "ParcelVoiceInfoRequest", + new RestStreamHandler( + "POST", + capsBase + m_parcelVoiceInfoRequestPath, + (request, path, param, httpRequest, httpResponse) + => ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps), + "ParcelVoiceInfoRequest", + agentID.ToString())); + + caps.RegisterHandler( + "ChatSessionRequest", + new RestStreamHandler( + "POST", + capsBase + m_chatSessionRequestPath, + (request, path, param, httpRequest, httpResponse) + => ChatSessionRequest(scene, request, path, param, agentID, caps), + "ChatSessionRequest", + agentID.ToString())); } /// diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 738133c..a36fd74 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -406,30 +406,36 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice m_log.DebugFormat("[VivoxVoice] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); string capsBase = "/CAPS/" + caps.CapsObjectPath; - caps.RegisterHandler("ProvisionVoiceAccountRequest", - new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, - delegate(string request, string path, string param, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - return ProvisionVoiceAccountRequest(scene, request, path, param, - agentID, caps); - })); - caps.RegisterHandler("ParcelVoiceInfoRequest", - new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, - delegate(string request, string path, string param, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - return ParcelVoiceInfoRequest(scene, request, path, param, - agentID, caps); - })); - caps.RegisterHandler("ChatSessionRequest", - new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, - delegate(string request, string path, string param, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - return ChatSessionRequest(scene, request, path, param, - agentID, caps); - })); + + caps.RegisterHandler( + "ProvisionVoiceAccountRequest", + new RestStreamHandler( + "POST", + capsBase + m_provisionVoiceAccountRequestPath, + (request, path, param, httpRequest, httpResponse) + => ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps), + "ProvisionVoiceAccountRequest", + agentID.ToString())); + + caps.RegisterHandler( + "ParcelVoiceInfoRequest", + new RestStreamHandler( + "POST", + capsBase + m_parcelVoiceInfoRequestPath, + (request, path, param, httpRequest, httpResponse) + => ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps), + "ParcelVoiceInfoRequest", + agentID.ToString())); + + caps.RegisterHandler( + "ChatSessionRequest", + new RestStreamHandler( + "POST", + capsBase + m_chatSessionRequestPath, + (request, path, param, httpRequest, httpResponse) + => ChatSessionRequest(scene, request, path, param, agentID, caps), + "ChatSessionRequest", + agentID.ToString())); } /// -- cgit v1.1 From 916e3bf886ee622e2f18d6eb74f90fee8c630471 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Jul 2012 22:54:22 +0100 Subject: Where possible, use the system Encoding.ASCII and Encoding.UTF8 rather than constructing fresh copies. The encodings are thread-safe and already used in such a manner in other places. This isn't done where Byte Order Mark output is suppressed, since Encoding.UTF8 is constructed to output the BOM. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index be8873d..7fafdc6 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -823,11 +823,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", landName, land.LocalID, landUUID); } - System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. - channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); + channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(Encoding.ASCII.GetBytes(landUUID)), m_freeSwitchRealm); lock (m_ParcelAddress) { -- cgit v1.1 From e041f09750419f60c819ee7e7a99044fe43a811c Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Thu, 6 Sep 2012 11:45:52 +0100 Subject: refactoring to allow Scene.GetLandData to accept Vector3 as an argument. Note that the prior work on LSL_Vector implicit operators means one does not need to explicitly cast a LSL_Vector to Vector3 --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 2 +- .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 7fafdc6..37ab35a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -447,7 +447,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel - LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + LandData land = scene.GetLandData(avatar.AbsolutePosition); //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index a36fd74..c5fcef4 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -623,7 +623,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel - LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + LandData land = scene.GetLandData(avatar.AbsolutePosition); m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); -- cgit v1.1 From 531edd51d82ecd6a842a2611c99e9919634491ef Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Sep 2012 07:22:55 -0700 Subject: Added request.Proxy=null everywhere, as discussed in http://stackoverflow.com/questions/2519655/httpwebrequest-is-extremely-slow. Thanks R.Gunther (rigun@rigutech.nl) https://lists.berlios.de/pipermail/opensim-users/2012-September/010986.html --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 1 + .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 37ab35a..8a5ce62 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -541,6 +541,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice forwardreq.Method = method; forwardreq.ContentType = contenttype; forwardreq.KeepAlive = false; + forwardreq.Proxy = null; if (method == "POST") { diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index c5fcef4..f5d8e19 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -1119,6 +1119,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // We are sending just parameters, no content req.ContentLength = 0; + req.Proxy = null; // Send request and retrieve the response rsp = (HttpWebResponse)req.GetResponse(); -- cgit v1.1 From 91a5c602e313b96ffaf1d50b7f0d2923a2e141ba Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Sep 2012 07:48:03 -0700 Subject: Revert "Added request.Proxy=null everywhere, as discussed in http://stackoverflow.com/questions/2519655/httpwebrequest-is-extremely-slow." But the patch is here, in case anyone wants to try it. This reverts commit 531edd51d82ecd6a842a2611c99e9919634491ef. --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 1 - .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 1 - 2 files changed, 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 8a5ce62..37ab35a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -541,7 +541,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice forwardreq.Method = method; forwardreq.ContentType = contenttype; forwardreq.KeepAlive = false; - forwardreq.Proxy = null; if (method == "POST") { diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index f5d8e19..c5fcef4 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -1119,7 +1119,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // We are sending just parameters, no content req.ContentLength = 0; - req.Proxy = null; // Send request and retrieve the response rsp = (HttpWebResponse)req.GetResponse(); -- cgit v1.1 From 18c5d33f0a6ccd08261e753f7bc9834708a1c777 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 13 Nov 2012 09:48:56 -0800 Subject: All optional modules' directives moved out of addin.xml --- .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index c5fcef4..881807a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -36,6 +36,7 @@ using System.Reflection; using System.Threading; using OpenMetaverse; using log4net; +using Mono.Addins; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; @@ -49,6 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice { + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "VivoxVoiceModule")] public class VivoxVoiceModule : ISharedRegionModule { -- cgit v1.1 From 80c19b7cac52a57fd04966169c657400aeee3de8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 27 Feb 2013 00:21:02 +0000 Subject: Make sure we dispose of WebResponse, StreamReader and Stream in various places where we were not already. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 21 ++++++++++++++------- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 12 +++++------- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 37ab35a..ef1b92e 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -551,13 +551,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice reqStream.Close(); } - HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse(); - Encoding encoding = Util.UTF8; - StreamReader fwdresponsestream = new StreamReader(fwdrsp.GetResponseStream(), encoding); - fwdresponsestr = fwdresponsestream.ReadToEnd(); - fwdresponsecontenttype = fwdrsp.ContentType; - fwdresponsecode = (int)fwdrsp.StatusCode; - fwdresponsestream.Close(); + using (HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse()) + { + Encoding encoding = Util.UTF8; + + using (Stream s = fwdrsp.GetResponseStream()) + { + using (StreamReader fwdresponsestream = new StreamReader(s)) + { + fwdresponsestr = fwdresponsestream.ReadToEnd(); + fwdresponsecontenttype = fwdrsp.ContentType; + fwdresponsecode = (int)fwdrsp.StatusCode; + } + } + } response["content_type"] = fwdresponsecontenttype; response["str_response_string"] = fwdresponsestr; diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 881807a..cb69411 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -1116,18 +1116,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // Otherwise prepare the request m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); - HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); - HttpWebResponse rsp = null; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); // We are sending just parameters, no content req.ContentLength = 0; // Send request and retrieve the response - rsp = (HttpWebResponse)req.GetResponse(); - - XmlTextReader rdr = new XmlTextReader(rsp.GetResponseStream()); - doc.Load(rdr); - rdr.Close(); + using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) + using (Stream s = rsp.GetResponseStream()) + using (XmlTextReader rdr = new XmlTextReader(s)) + doc.Load(rdr); } catch (Exception e) { -- cgit v1.1 From 7e1c7f54c719910145a88bfebf16435b9f142901 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 28 May 2013 20:59:25 -0700 Subject: First change in Vivox for ages! -- added a lock to serialize calls to vivox servers. This may ameliorate things when lots of avies arrive in a sim at about the same time. Turns out that there are 4 http requests per avie to Vivox. --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 39 ++++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index cb69411..db4869d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -117,6 +117,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice private IConfig m_config; + private object m_Lock; + public void Initialise(IConfigSource config) { @@ -128,6 +130,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice if (!m_config.GetBoolean("enabled", false)) return; + m_Lock = new object(); + try { // retrieve configuration variables @@ -1111,25 +1115,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice doc = new XmlDocument(); - try + // Let's serialize all calls to Vivox. Most of these are driven by + // the clients (CAPs), when the user arrives at the region. We don't + // want to issue many simultaneous http requests to Vivox, because mono + // doesn't like that + lock (m_Lock) { - // Otherwise prepare the request - m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); + try + { + // Otherwise prepare the request + m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); - HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); - // We are sending just parameters, no content - req.ContentLength = 0; + // We are sending just parameters, no content + req.ContentLength = 0; - // Send request and retrieve the response - using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) + // Send request and retrieve the response + using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) using (Stream s = rsp.GetResponseStream()) - using (XmlTextReader rdr = new XmlTextReader(s)) - doc.Load(rdr); - } - catch (Exception e) - { - m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); + using (XmlTextReader rdr = new XmlTextReader(s)) + doc.Load(rdr); + } + catch (Exception e) + { + m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); + } } // If we're debugging server responses, dump the whole -- cgit v1.1 From 12a3b855619735b2e36a67ab99027029c8b57260 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 30 May 2013 22:20:02 +0100 Subject: Fix passing of voice distance attenuation to the Vivox voice server. Because of a typo, this wasn't being done at all - now the 'default' value as described in OpenSimDefaults.ini of 10m is passed (vivox_channel_clamping_distance) Thanks to Ai Austin for spotting this. --- .../Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index db4869d..2d65530 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -836,7 +836,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice requrl = String.Format("{0}&chan_roll_off={1}", requrl, m_vivoxChannelRollOff); requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel); requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange); - requrl = String.Format("{0}&chan_ckamping_distance={1}", requrl, m_vivoxChannelClampingDistance); + requrl = String.Format("{0}&chan_clamping_distance={1}", requrl, m_vivoxChannelClampingDistance); XmlElement resp = VivoxCall(requrl, true); if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri)) -- cgit v1.1 From 428916a64d27e5f00e74d34fd4b0453f32c3d2de Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Jul 2013 21:14:21 -0700 Subject: Commented out ChatSessionRequest capability in Vivox and Freeswitch. We aren't processing it in any meaningful way, and it seems to get invoked everytime someone types a message in group chat. --- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 18 +++++++++--------- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index ef1b92e..5a5a70c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -326,15 +326,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice "ParcelVoiceInfoRequest", agentID.ToString())); - caps.RegisterHandler( - "ChatSessionRequest", - new RestStreamHandler( - "POST", - capsBase + m_chatSessionRequestPath, - (request, path, param, httpRequest, httpResponse) - => ChatSessionRequest(scene, request, path, param, agentID, caps), - "ChatSessionRequest", - agentID.ToString())); + //caps.RegisterHandler( + // "ChatSessionRequest", + // new RestStreamHandler( + // "POST", + // capsBase + m_chatSessionRequestPath, + // (request, path, param, httpRequest, httpResponse) + // => ChatSessionRequest(scene, request, path, param, agentID, caps), + // "ChatSessionRequest", + // agentID.ToString())); } /// diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 2d65530..cdab116 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -433,15 +433,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice "ParcelVoiceInfoRequest", agentID.ToString())); - caps.RegisterHandler( - "ChatSessionRequest", - new RestStreamHandler( - "POST", - capsBase + m_chatSessionRequestPath, - (request, path, param, httpRequest, httpResponse) - => ChatSessionRequest(scene, request, path, param, agentID, caps), - "ChatSessionRequest", - agentID.ToString())); + //caps.RegisterHandler( + // "ChatSessionRequest", + // new RestStreamHandler( + // "POST", + // capsBase + m_chatSessionRequestPath, + // (request, path, param, httpRequest, httpResponse) + // => ChatSessionRequest(scene, request, path, param, agentID, caps), + // "ChatSessionRequest", + // agentID.ToString())); } /// -- cgit v1.1 From 7cab41f4223b7febd3fdd42fa7cfefef25e4a9c9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Nov 2013 21:45:08 +0000 Subject: refactor: replace verbose checks with String.IsNullOrEmpty where applicable. Thanks to Kira for this patch from http://opensimulator.org/mantis/view.php?id=6845 --- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index cdab116..b4fae9d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -822,11 +822,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice { string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", channelId, m_authToken); - if (parent != null && parent != String.Empty) + if (!string.IsNullOrEmpty(parent)) { requrl = String.Format("{0}&chan_parent={1}", requrl, parent); } - if (description != null && description != String.Empty) + if (!string.IsNullOrEmpty(description)) { requrl = String.Format("{0}&chan_desc={1}", requrl, description); } @@ -862,7 +862,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // requrl = String.Format("{0}&chan_parent={1}", requrl, parent); // } - if (description != null && description != String.Empty) + if (!string.IsNullOrEmpty(description)) { requrl = String.Format("{0}&chan_desc={1}", requrl, description); } @@ -1047,7 +1047,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice private XmlElement VivoxDeleteChannel(string parent, string channelid) { string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken); - if (parent != null && parent != String.Empty) + if (!string.IsNullOrEmpty(parent)) { requrl = String.Format("{0}&chan_parent={1}", requrl, parent); } -- cgit v1.1 From 998d7009a65def0a4debc9369d35b63611db5b55 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 22 Apr 2014 20:04:12 +0300 Subject: Eliminated many warnings --- .../Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 2 +- .../OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 5a5a70c..45af212 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -65,7 +65,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice // Capability string prefixes private static readonly string m_parcelVoiceInfoRequestPath = "0207/"; private static readonly string m_provisionVoiceAccountRequestPath = "0208/"; - private static readonly string m_chatSessionRequestPath = "0209/"; + //private static readonly string m_chatSessionRequestPath = "0209/"; // Control info private static bool m_Enabled = false; diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index b4fae9d..dd44564 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // Capability strings private static readonly string m_parcelVoiceInfoRequestPath = "0107/"; private static readonly string m_provisionVoiceAccountRequestPath = "0108/"; - private static readonly string m_chatSessionRequestPath = "0109/"; + //private static readonly string m_chatSessionRequestPath = "0109/"; // Control info, e.g. vivox server, admin user, admin password private static bool m_pluginEnabled = false; @@ -1325,4 +1325,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice return false; } } -} \ No newline at end of file +} -- cgit v1.1