private static void _ReloadConfigurations() { string ip = "127.0.0.1"; int port = 8021; string password = "******"; sFreeSwitchModuleFile swm = CoreGenerator.ReadCurrentModuleSettings("event_socket"); if (swm != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml("<?xml version=\"1.0\"?>" + swm.ConfigurationSectionString); foreach (XmlNode node in doc.GetElementsByTagName("param")) { if (!(node is XmlComment)) { switch (node.Attributes["name"].Value) { case "listen_port": port = int.Parse(node.Attributes["value"].Value); break; case "password": password = node.Attributes["value"].Value; break; } } } } TcpClient cl = new TcpClient(); cl.Connect(new IPEndPoint(IPAddress.Parse(ip), port)); cl.Client.Send(ASCIIEncoding.ASCII.GetBytes(string.Format(_RELOAD_CONFIGS_COMMAND, password))); cl.Close(); }
public static void ProcessChanges() { Monitor.Enter(_lock); ArrayList changes = _Changes; List <IEvent> events = new List <IEvent>(); if (changes != null) { foreach (object obj in changes) { if (obj is RegisteredConfigurationRegenerationCall) { RegisteredConfigurationRegenerationCall rcgc = (RegisteredConfigurationRegenerationCall)obj; if (rcgc.TriggerEvents != null) { foreach (IEvent ev in rcgc.TriggerEvents) { events.Add(ev); } } foreach (ADialPlan.sUpdateConfigurationsCall ucc in rcgc.ConfigurationCalls) { CallControlManager.UpdateDialPlan(Utility.LocateType(rcgc.DialPlanType), ucc); } } else if (obj is RegisteredExtensionRegenerationCall) { RegisteredExtensionRegenerationCall regc = (RegisteredExtensionRegenerationCall)obj; if (regc.TriggerEvents != null) { foreach (IEvent ev in regc.TriggerEvents) { events.Add(ev); } } foreach (ADialPlan.sUpdateConfigurationsCall ucc in regc.ConfigurationCalls) { CallControlManager.UpdateDialPlan(Utility.LocateType(regc.DialPlanType), ucc); } CoreGenerator.RegenerateExtensionFiles(regc.ExtensionNumber, Domain.Load(regc.Domain)); } else if (obj is string) { if (((string)obj).StartsWith(string.Format(_MODULE_FILE_FORMAT, ""))) { string mod = ((string)obj).Substring(string.Format(_MODULE_FILE_FORMAT, "").Length); CoreGenerator.RegenerateModuleFile(mod); EventController.TriggerEvent(new FreeswitchModuleRedeployedEvent(mod)); } else if (((string)obj).StartsWith(string.Format(_DEPLOY_TRUNK_FORMAT, ""))) { string depTrunkName = ((string)obj).Substring(string.Format(_DEPLOY_TRUNK_FORMAT, "").Length); CoreGenerator.GenerateOutgoingSIPTrunkConfiguration(depTrunkName); EventController.TriggerEvent(new GenericEvent("OutgoingSIPTrunkCreated", new NameValuePair[] { new NameValuePair("Name", depTrunkName) })); } else if (((string)obj).StartsWith(string.Format(_DESTROY_TRUNK_FORMAT, ""))) { string desTrunkName = ((string)obj).Substring(string.Format(_DESTROY_TRUNK_FORMAT, "").Length); string desProfileName = desTrunkName.Split('@')[1]; desTrunkName = desTrunkName.Substring(0, desTrunkName.IndexOf("@")); CoreGenerator.DestroyOutgoingSIPTrunk(desTrunkName, desProfileName); EventController.TriggerEvent(new GenericEvent("OutgoingSIPTrunkDeleted", new NameValuePair[] { new NameValuePair("Name", desTrunkName), new NameValuePair("ProfileName", desProfileName) })); } else if (((string)obj).StartsWith(string.Format(_DEPLOY_INCOMING_TRUNK_FORMAT, ""))) { string depIncomingTrunkName = ((string)obj).Substring(string.Format(_DEPLOY_INCOMING_TRUNK_FORMAT, "").Length); string depIncomingDomainName = depIncomingTrunkName.Split('@')[1]; depIncomingTrunkName = depIncomingTrunkName.Substring(0, depIncomingTrunkName.IndexOf("@")); CoreGenerator.RegenerateIncomingSIPTrunkFile(depIncomingTrunkName, Domain.Load(depIncomingDomainName)); EventController.TriggerEvent(new GenericEvent("IncomingSIPTrunkDeployed", new NameValuePair[] { new NameValuePair("Name", depIncomingTrunkName), new NameValuePair("Domain", depIncomingDomainName) })); } else if (((string)obj).StartsWith(string.Format(_DESTROY_INCOMING_TRUNK_FORMAT, ""))) { string desIncomingTrunkName = ((string)obj).Substring(string.Format(_DESTROY_INCOMING_TRUNK_FORMAT, "").Length); string desIncomingDomainName = desIncomingTrunkName.Split('@')[1]; desIncomingTrunkName = desIncomingTrunkName.Substring(0, desIncomingTrunkName.IndexOf("@")); CoreGenerator.DestroyIncomingSIPTrunkFile(desIncomingTrunkName, desIncomingDomainName); EventController.TriggerEvent(new GenericEvent("IncomingSIPTrunkDestroyed", new NameValuePair[] { new NameValuePair("Name", desIncomingTrunkName), new NameValuePair("Domain", desIncomingDomainName) })); } } } } _Changes = null; if (ModuleController.Current.IsModuleEnabled("ESL")) { ModuleController.Current.InvokeModuleMethod("ESL", "ReloadConfigs", false); } else { _ReloadConfigurations(); } foreach (IEvent ie in events) { EventController.TriggerEvent(ie); } Monitor.Exit(_lock); }