Change the freeswitch out connector (which is pointless) to an in connector

arthursv
Melanie 2009-08-04 04:32:44 +01:00
parent afc318f30b
commit 2b8c3f8519
1 changed files with 44 additions and 59 deletions

View File

@ -25,77 +25,42 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using System.Reflection;
using System.Collections.Generic;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Server.Base; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Freeswitch
{ {
public class FreeswitchServicesConnector : public class FreeswitchServiceInConnectorModule : ISharedRegionModule
ISharedRegionModule
{ {
private static readonly ILog m_log = private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
LogManager.GetLogger( private static bool m_Enabled = false;
MethodBase.GetCurrentMethod().DeclaringType);
private IConfigSource m_Config;
bool m_Registered = false;
private IFreeswitchService m_FreeswitchService; #region IRegionModule interface
private bool m_Enabled = false; public void Initialise(IConfigSource config)
public Type ReplacableInterface
{ {
get { return null; } m_Config = config;
} IConfig moduleConfig = config.Configs["Modules"];
public string Name
{
get { return "FreeswitchServicesConnector"; }
}
public void Initialise(IConfigSource source)
{
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null) if (moduleConfig != null)
{ {
string name = moduleConfig.GetString("FreeswitchServices", ""); m_Enabled = moduleConfig.GetBoolean("FreeswitchServiceInConnector", false);
if (name == Name) if (m_Enabled)
{ {
IConfig freeswitchConfig = source.Configs["FreeswitchService"]; m_log.Info("[FREESWITCH IN CONNECTOR]: FreeswitchServiceInConnector enabled");
if (freeswitchConfig == null)
{
m_log.Error("[FREESWITCH CONNECTOR]: FreeswitchService missing from OpenSim.ini");
return;
}
string serviceDll = freeswitchConfig.GetString("LocalServiceModule",
String.Empty);
if (serviceDll == String.Empty)
{
m_log.Error("[FREESWITCH CONNECTOR]: No LocalServiceModule named in section FreeswitchService");
return;
}
Object[] args = new Object[] { source };
m_FreeswitchService =
ServerUtils.LoadPlugin<IFreeswitchService>(serviceDll,
args);
if (m_FreeswitchService == null)
{
m_log.Error("[FREESWITCH CONNECTOR]: Can't load freeswitch service");
return;
}
m_Enabled = true;
m_log.Info("[FREESWITCH CONNECTOR]: Freeswitch connector enabled");
} }
} }
} }
@ -107,14 +72,31 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
{ {
} }
public Type ReplacableInterface
{
get { return null; }
}
public string Name
{
get { return "RegionFreeswitchService"; }
}
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
if (!m_Enabled) if (!m_Enabled)
return; return;
m_log.InfoFormat("[FREESWITCH CONNECTOR]: Enabled freeswitch for region {0}", scene.RegionInfo.RegionName); if (!m_Registered)
{
m_Registered = true;
scene.RegisterModuleInterface<IFreeswitchService>(m_FreeswitchService); m_log.Info("[RegionFreeswitchService]: Starting...");
Object[] args = new Object[] { m_Config, MainServer.Instance };
ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:FreeswitchServiceConnector", args);
}
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -124,5 +106,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
} }
#endregion
} }
} }