private void btnConnect_Click(object sender, EventArgs e) { string address = this.tbAddress.Text; int port = int.Parse(this.tbPort.Text); string user = this.tbUser.Text; string password = this.tbPassword.Text; btnConnect.Enabled = false; manager = new ManagerConnection(address, port, user, password); manager.UnhandledEvent += new ManagerEventHandler(manager_Events); try { // Uncomment next 2 line comments to Disable timeout (debug mode) // manager.DefaultResponseTimeout = 0; // manager.DefaultEventTimeout = 0; manager.Login(); } catch(Exception ex) { MessageBox.Show("Error connect\n" + ex.Message); manager.Logoff(); this.Close(); } btnDisconnect.Enabled = true; }
public AsteriskConnector() { InitializeComponent(); try { //Trace.Listeners.Add(new TextWriterTraceListener("asteriskconnector.log")); log.Debug("Initializing asterisk connector..."); string address = Properties.Settings.Default.AsteriskServer; int port = Convert.ToInt32(Properties.Settings.Default.AsteriskPort); string user = Properties.Settings.Default.AsteriskUser; string password = Properties.Settings.Default.AsteriskUserPassword; log.Debug("Creating new manager connection: " + address + ":" + port + " as " + user); manager = new ManagerConnection(address, port, user, password); manager.PingInterval = Properties.Settings.Default.AsteriskPingInterval; manager.KeepAlive = true; manager.FireAllEvents = true; manager.UnhandledEvent += new ManagerEventHandler(manager_UnhandledEvent); log.Debug("Creating StateServer Proxy: "); ss = new StateServer(Properties.Settings.Default.StateServerUrl); log.Debug("Creating AsteriskCTIService..."); acs = new AsteriskCTIService(manager); host = new ServiceHost(acs); log.Debug("Hosting AsteriskCTIService..."); host.Open(); } catch (Exception e) { log.Debug("Error while initializing AsteriskConnector: " + e.Message); } }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="events">the ResponseEvents to store the events in</param> /// <param name="actionCompleteEventClass">the type of event that indicates that all events have been received</param> /// <param name="thread">the thread to interrupt when the actionCompleteEventClass has been received</param> public ResponseEventHandler(ManagerConnection connection, ManagerActionEvent action, AutoResetEvent autoEvent) { this.connection = connection; this.events = new ResponseEvents(); this.action = action; this.autoEvent = autoEvent; }
public void Call(Asterisk.NET.Manager.ManagerConnection manager, string lineIPPBX, string phoneNumber) { G_Timer.Start(); //System.Threading.Thread.Sleep(200); QuaySoGoiDien(manager, lineIPPBX, phoneNumber); //System.Threading.Thread.Sleep(2000); //this.Hide(); }
/// <summary> /// Creates a new ManagerReader. /// </summary> /// <param name="dispatcher">the dispatcher to use for dispatching events and responses.</param> public ManagerReader(ManagerConnection connection) { this.mrConnector = connection; this.die = false; lineQueue = new Queue<string>(); packet = new Dictionary<string, string>(); commandList = new List<string>(); }
static void Main(string[] args) { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); manager.PingInterval = 0; // +++ try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } if (args.Count() == 4) { string originateChannel = args[0]; string originateCallerId = args[1]; string originateExten = args[2]; string originateContext = args[3]; //string originateChannel = "SIP/billy"; //string originateCallerId = "<1001>"; //string originateExten = "1002"; //string originateContext = "phones"; OriginateAction oc = new OriginateAction(); //oc.Channel = originateChannel; //oc.CallerId = originateCallerId; //oc.Context = originateContext; //oc.Exten = originateExten; //oc.Priority = 2; //oc.Timeout = 15000; oc.Channel = originateChannel; oc.CallerId = originateCallerId; oc.Application = "Dial"; oc.Data = "Local/" + originateExten + "@" + originateContext; oc.Timeout = 15000; try { ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); } catch (Exception e) { Console.WriteLine("error: {0}", e.Message); } } manager.Logoff(); }
public void Free() { connection = null; autoEvent = null; action = null; events.Events.Clear(); events.Response = null; events = null; }
private void btnDisconnect_Click(object sender, EventArgs e) { btnConnect.Enabled = true; if (this.manager != null) { manager.Logoff(); this.manager = null; } btnDisconnect.Enabled = false; }
private static void displayQueue() { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); try { #if NOTIMEOUT manager.Connection.DefaultTimeout = 0; manager.Connection.DefaultEventTimeout = 0; #endif manager.Login(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); return; } ResponseEvents re; try { re = manager.SendEventGeneratingAction(new QueueStatusAction()); } catch (EventTimeoutException e) { // this happens with Asterisk 1.0.x as it doesn't send a QueueStatusCompleteEvent re = e.PartialResult; } foreach (ManagerEvent e in re.Events) { if (e is QueueParamsEvent) { QueueParamsEvent qe = (QueueParamsEvent)e; Console.WriteLine("QueueParamsEvent" + "\n\tQueue:\t\t" + qe.Queue + "\n\tServiceLevel:\t" + qe.ServiceLevel); } else if (e is QueueMemberEvent) { QueueMemberEvent qme = (QueueMemberEvent)e; Console.WriteLine("QueueMemberEvent" + "\n\tQueue:\t\t" + qme.Queue + "\n\tLocation:\t" + qme.Location); } else if (e is QueueEntryEvent) { QueueEntryEvent qee = (QueueEntryEvent)e; Console.WriteLine("QueueEntryEvent" + "\n\tQueue:\t\t" + qee.Queue + "\n\tChannel:\t" + qee.Channel + "\n\tPosition:\t" + qee.Position); } } Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); }
private bool QuaySoGoiDien(Asterisk.NET.Manager.ManagerConnection manager, string line, string phoneNumber) { bool bRet = false; const string ORIGINATE_CONTEXT = "from-internal"; if (manager == null) { return(false); } try { if (!manager.IsConnected()) { manager = new ManagerConnection(AsteriskInfo.AST_HOSTNAME, AsteriskInfo.AST_PORT_NUMBER, AsteriskInfo.AST_USERNAME, AsteriskInfo.AST_PASSWORD); manager.Login(); } if (manager.IsConnected()) { Text = "Gọi đi : Kết nối tổng đài IP thành công"; } else { Text = "Gọi đi : Kết nối tổng đài IP thất bại !!!"; } OriginateAction oc = new OriginateAction(); oc.Context = ORIGINATE_CONTEXT; oc.Priority = 1; oc.Channel = "SIP/" + line; oc.CallerId = line; oc.Exten = phoneNumber; oc.Timeout = 30000; ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); if (originateResponse.IsSuccess()) { bRet = true; } else { bRet = false; } } catch (Exception ex) { LogError.WriteLogError("QuaySoGoiDien2", ex); } return(bRet); }
public void makeCall(string channel, string exten, string id) { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); // Register user event class manager.RegisterUserEventClass(typeof(UserAgentLoginEvent)); // Add or Remove events manager.UserEvents += new UserEventHandler(dam_UserEvents); // Dont't display this event manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent); // Display all other manager.UnhandledEvent += new ManagerEventHandler(dam_Events); // +++ Only to debug purpose manager.FireAllEvents = true; // manager.DefaultEventTimeout = 0; // manager.DefaultResponseTimeout = 0; manager.PingInterval = 0; try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } { //Console.WriteLine("\nGetConfig action"); ManagerResponse response = manager.SendAction(new GetConfigAction("manager.conf")); if (response.IsSuccess()) { GetConfigResponse responseConfig = (GetConfigResponse)response; foreach (int key in responseConfig.Categories.Keys) { //Console.WriteLine(string.Format("{0}:{1}", key, responseConfig.Categories[key])); /*foreach (int keyLine in responseConfig.Lines(key).Keys) { Console.WriteLine(string.Format("\t{0}:{1}", keyLine, responseConfig.Lines(key)[keyLine])); }*/ } } else { } //Console.WriteLine(response); } { // Console.WriteLine("\nUpdateConfig action"); UpdateConfigAction config = new UpdateConfigAction("manager.conf", "manager.conf"); config.AddCommand(UpdateConfigAction.ACTION_NEWCAT, "testadmin"); config.AddCommand(UpdateConfigAction.ACTION_APPEND, "testadmin", "secret", "blabla"); ManagerResponse response = manager.SendAction(config); //Console.WriteLine(response); } // Originate call example //Console.WriteLine("\nPress ENTER key to originate call.\n" // + "Start phone (or connect) or make a call to see events.\n" // + "After all events press a key to originate call."); //Console.ReadLine(); //while(true) //{ OriginateAction oc = new OriginateAction(); oc.Context = ORIGINATE_CONTEXT; oc.Priority = 1; //Console.WriteLine("Channel: "); oc.Channel = channel; oc.CallerId = id; oc.Exten = exten; oc.Timeout = ORIGINATE_TIMEOUT; // oc.Variable = "VAR1=abc|VAR2=def"; // oc.SetVariable("VAR3", "ghi"); /*string outnumber = "SOFTPHONE001"; string extension = "SIP/SOFTPHONE001"; OriginateAction action = new OriginateAction(); action.Exten = extension; //action.Channel = "LOCAL/98323687387"; action.Channel = @"Local/" + "8323687387" + "@from-internal"; action.Context = "from-local"; action.Priority = 1; action.CallerId = "Sean you are lame"; action.Timeout = 30000;*/ ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); Console.WriteLine("Response:"); Console.WriteLine(originateResponse); Console.WriteLine("Press ENTER key to next test."); Console.ReadLine(); }
public AsteriskCTIService(ManagerConnection manager) { _manager = manager; }
private void submitBtn_Click(object sender, EventArgs e) { try { manager = new ManagerConnection(this.AsteriskHost.Text, int.Parse(this.AsteriskPort.Text), this.AsteriskUsername.Text, this.AsteriskPassword.Text); manager.Login(); if (manager.IsConnected()) { controlGroup.Enabled = true; credentialGroup.Enabled = false; MessageBox.Show(this, String.Format("{0} was Successfuly Initiated", AsteriskHost.Text), "Asterisk Message", MessageBoxButtons.OK, MessageBoxIcon.Information); AsteriskLogs.Text = "***WELCOME***"; // Set up AMI Eventhandlers manager.OriginateResponse += new OriginateResponseEventHandler(manager_OriginateResponse); manager.NewChannel += new NewChannelEventHandler(manager_NewChannel); manager.Hangup += new HangupEventHandler(manager_Hangup); manager.ExtensionStatus += new ExtensionStatusEventHandler(manager_ExtensionStatus); // Set up AMI properties manager.DefaultEventTimeout = 300000; manager.DefaultResponseTimeout = 300000; manager.KeepAlive = true; manager.KeepAliveAfterAuthenticationFailure = true; manager.FireAllEvents = true; data = new AsteriskData(); // set up user eventhandlers onStartCall += new onOriginate(AsteriskForm_onOriginateAction); onEndCall += new onHangup(AsteriskForm_onEndCall); } else throw new Exception("Error on Asterisk login"); } catch (Exception ex) { MessageBox.Show(this, String.Format("{0} was unSuccessfuly Initiated{1}Error Message: {2}", AsteriskHost.Text, Environment.NewLine, ex.Message), "Asterisk Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Builds the event based on the given map of attributes and the registered event classes. /// </summary> /// <param name="source">source attribute for the event</param> /// <param name="attributes">map containing event attributes</param> /// <returns>a concrete instance of ManagerEvent or <code>null</code> if no event class was registered for the event type.</returns> internal static ManagerEvent BuildEvent(IDictionary<int, ConstructorInfo> list, ManagerConnection source, Dictionary<string, string> attributes) { ManagerEvent e; string eventType; ConstructorInfo constructor = null; int hash, hashEvent; eventType = ((string)attributes["event"]).ToLower(Helper.CultureInfo); // Remove Event tail from event name (ex. JabberEvent) if (eventType.EndsWith("event")) eventType = eventType.Substring(0, eventType.Length - 5); hashEvent = eventType.GetHashCode(); if (eventType == "user") { string userevent = ((string)attributes["userevent"]).ToLower(Helper.CultureInfo); hash = string.Concat(eventType, userevent).GetHashCode(); if(list.ContainsKey(hash)) constructor = list[hash]; else constructor = list[hashEvent]; } else if (list.ContainsKey(hashEvent)) constructor = list[hashEvent]; if (constructor == null) e = new UnknownEvent(source); else { try { e = (ManagerEvent)constructor.Invoke(new object[] { source }); } catch (Exception ex) { #if LOGGER logger.Error("Unable to create new instance of " + eventType, ex); return null; #else throw ex; #endif } } SetAttributes(e, attributes); // ResponseEvents are sent in response to a ManagerAction if the // response contains lots of data. They include the actionId of // the corresponding ManagerAction. if (e is ResponseEvent) { ResponseEvent responseEvent = (ResponseEvent)e; string actionId = responseEvent.ActionId; if (actionId != null) { responseEvent.ActionId = Helper.StripInternalActionId(actionId); responseEvent.InternalActionId = Helper.GetInternalActionId(actionId); } } return e; }
private static void checkManagerAPI() { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); manager.NewState += new NewStateEventHandler(dam_NewStateEvent); manager.Dial += new DialEventHandler(dam_Dial); manager.PingInterval = 0; // +++ try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } Console.ReadLine(); manager.Logoff(); }
private static void checkManagerAPI() { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); // Register user event class manager.RegisterUserEventClass(typeof(UserAgentLoginEvent)); // Add or Remove events manager.UserEvents += new UserEventHandler(dam_UserEvents); // Dont't display this event //manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent); manager.NewExten += new NewExtenEventHandler(manager_HandleNewExtentEvent); // Display all other manager.UnhandledEvent += new ManagerEventHandler(dam_Events); // Handle the response from AGI Exec manager.AGIExec += new AGIExecHandler(manager_AgiEvent); // +++ Only to debug purpose manager.FireAllEvents = true; // manager.DefaultEventTimeout = 0; // manager.DefaultResponseTimeout = 0; manager.PingInterval = 0; // +++ try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } { Console.WriteLine("\nGetConfig action"); ManagerResponse response = manager.SendAction(new GetConfigAction("manager.conf")); if (response.IsSuccess()) { GetConfigResponse responseConfig = (GetConfigResponse)response; foreach (int key in responseConfig.Categories.Keys) { Console.WriteLine(string.Format("{0}:{1}", key, responseConfig.Categories[key])); foreach (int keyLine in responseConfig.Lines(key).Keys) { Console.WriteLine(string.Format("\t{0}:{1}", keyLine, responseConfig.Lines(key)[keyLine])); } } } else Console.WriteLine(response); } { Console.WriteLine("\nUpdateConfig action"); UpdateConfigAction config = new UpdateConfigAction("manager.conf", "manager.conf"); config.AddCommand(UpdateConfigAction.ACTION_NEWCAT, "testadmin"); config.AddCommand(UpdateConfigAction.ACTION_APPEND, "testadmin", "secret", "blabla"); ManagerResponse response = manager.SendAction(config); Console.WriteLine(response); } // Originate call example Console.WriteLine("\nPress ENTER key to originate call.\n" + "Start phone (or connect) or make a call to see events.\n" + "After all events press a key to originate call."); Console.ReadLine(); OriginateAction oc = new OriginateAction(); oc.Context = ORIGINATE_CONTEXT; oc.Priority = "1"; // can be int in quotes or also be a label specified in the dial plan oc.Channel = ORIGINATE_CHANNEL; oc.CallerId = ORIGINATE_CALLERID; oc.Exten = ORIGINATE_EXTEN; oc.Timeout = ORIGINATE_TIMEOUT; // oc.Variable = "VAR1=abc|VAR2=def"; // oc.SetVariable("VAR3", "ghi"); ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); Console.WriteLine("Response:"); Console.WriteLine(originateResponse); Console.WriteLine("Press ENTER key to next test."); Console.ReadLine(); // // Display result of Show Queues command // { CommandAction command = new CommandAction(); CommandResponse response = new CommandResponse(); if (manager.AsteriskVersion == AsteriskVersion.ASTERISK_1_6) command.Command = "queue show"; else command.Command = "show queues"; try { response = (CommandResponse)manager.SendAction(command); Console.WriteLine("Result of " + command.Command); foreach (string str in response.Result) Console.WriteLine("\t" + str); } catch (Exception err) { Console.WriteLine("Response error: " + err); } Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); } // // Display Queues and Members // ResponseEvents re; try { re = manager.SendEventGeneratingAction(new QueueStatusAction()); } catch (EventTimeoutException e) { // this happens with Asterisk 1.0.x as it doesn't send a QueueStatusCompleteEvent re = e.PartialResult; } foreach (ManagerEvent e in re.Events) { if (e is QueueParamsEvent) { QueueParamsEvent qe = (QueueParamsEvent)e; Console.WriteLine("QueueParamsEvent" + "\n\tQueue:\t\t" + qe.Queue + "\n\tServiceLevel:\t" + qe.ServiceLevel); } else if (e is QueueMemberEvent) { QueueMemberEvent qme = (QueueMemberEvent)e; Console.WriteLine("QueueMemberEvent" + "\n\tQueue:\t\t" + qme.Queue + "\n\tLocation:\t" + qme.Location); } else if (e is QueueEntryEvent) { QueueEntryEvent qee = (QueueEntryEvent)e; Console.WriteLine("QueueEntryEvent" + "\n\tQueue:\t\t" + qee.Queue + "\n\tChannel:\t" + qee.Channel + "\n\tPosition:\t" + qee.Position); } } Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); // // To test create 3 extensions: // 1 - SIP/4012 w/o voicemail (with eyeBeam softphone) // 2 - IAX2/4008 w/o voicemail (with iaxComm softphone) // 3 - SIP/4010 w/ voicemal but no phone connect // RedirectCall: call from IAX2/4008 to SIP/4012 // Don't answer on SIP/4012 and call must redirect to SIP/4010 (to voicemail really) // Dial event used to define redirect channel Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC."); // Wait for Dial Event from ORIGINATE_CHANNEL DialEventHandler de = new DialEventHandler(dam_Dial); manager.Dial += de; while (transferChannel == null) { System.Threading.Thread.Sleep(100); if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) break; } manager.Dial -= de; // Now send Redirect action RedirectAction ra = new RedirectAction(); ra.Channel = transferChannel; ra.ExtraChannel = ORIGINATE_EXTRA_CHANNEL; ra.Context = ORIGINATE_CONTEXT; ra.Exten = ORIGINATE_EXTRA_EXTEN; ra.Priority = 1; try { ManagerResponse mr = manager.SendAction(ra, 10000); Console.WriteLine("Transfer Call" + "\n\tResponse:" + mr.Response + "\n\tMessage:" + mr.Message ); } catch (Exception ex) { Console.WriteLine(ex.Message); } // Monitor call. // Call from IA2/4008 to SIP/4012 // Link event used to define monitor channel Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC."); // Wait for Link event LinkEventHandler le = new LinkEventHandler(dam_Link); manager.Link += le; while (monitorChannel == null) { System.Threading.Thread.Sleep(100); if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) break; } manager.Link -= le; // Now send Monitor action MonitorAction ma = new MonitorAction(); ma.Channel = monitorChannel; ma.File = "voicefile"; ma.Format = "gsm"; ma.Mix = true; try { ManagerResponse mr = manager.SendAction(ma, 10000); Console.WriteLine("Monitor Call" + "\n\tResponse:" + mr.Response); } catch (Exception ex) { Console.WriteLine(ex.Message); } manager.Logoff(); }
public UserAgentLoginEvent(ManagerConnection source) : base(source) { }
/// <summary> /// Overall initialiser function which setups logging, creates the /// NHibernate session factory and connects to the Asterisk AMI interface /// </summary> void Init() { ConfigureLogging(); log.Debug("Asterisk Caller ID Lookup starting..."); try { //Initalise caller thumbnail folder and create if neccessary ThumbFolder = MediaPortal.Configuration.Config.GetFolder(Config.Dir.Thumbs) + @"\Acid\"; if (!Directory.Exists(ThumbFolder)) Directory.CreateDirectory(ThumbFolder); //create the NHibernate session factory wrapped around the Acid SQLite database SessionFactory = CreateSessionFactory(); //setup the various Asterisk notifications loading //the settings from the database using (ISession session = SessionFactory.OpenSession()) { AsteriskManager = new ManagerConnection(GetSetting(session, "ami_host", "localhost"), 5038, GetSetting(session, "ami_user", "admin"), GetSetting(session, "ami_password", "amp111")); AsteriskManager.UnhandledEvent += new ManagerEventHandler(AsteriskManager_UnhandledEvent); AsteriskManager.NewChannel += new NewChannelEventHandler(AsteriskManager_NewChannel); AsteriskManager.Hangup += new HangupEventHandler(AsteriskManager_Hangup); AsteriskManager.NewState += new NewStateEventHandler(AsteriskManager_NewState); AsteriskManager.KeepAlive = true; AsteriskManager.KeepAliveAfterAuthenticationFailure = true; AsteriskManagerConnect(null); } log.Debug("Asterisk Caller ID Looukp started"); } catch (Exception e) { log.Error("Failed to start Asterisk Caller ID Lookup", e); } InitComplete = true; }
private static void callPager(string pagerNum, string messageNum) { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); // Register user event class manager.RegisterUserEventClass(typeof(UserAgentLoginEvent)); // Add or Remove events manager.UserEvents += new UserEventHandler(dam_UserEvents); // Dont't display this event manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent); // Display all other manager.UnhandledEvent += new ManagerEventHandler(dam_Events); manager.PingInterval = 0; try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } { //Console.WriteLine("\nGetConfig action"); ManagerResponse response = manager.SendAction(new GetConfigAction("manager.conf")); if (response.IsSuccess()) { GetConfigResponse responseConfig = (GetConfigResponse)response; foreach (int key in responseConfig.Categories.Keys) { Console.WriteLine(string.Format("{0}:{1}", key, responseConfig.Categories[key])); foreach (int keyLine in responseConfig.Lines(key).Keys) { Console.WriteLine(string.Format("\t{0}:{1}", keyLine, responseConfig.Lines(key)[keyLine])); } } } else { } Console.WriteLine(response); } { // Console.WriteLine("\nUpdateConfig action"); UpdateConfigAction config = new UpdateConfigAction("manager.conf", "manager.conf"); config.AddCommand(UpdateConfigAction.ACTION_NEWCAT, "testadmin"); config.AddCommand(UpdateConfigAction.ACTION_APPEND, "testadmin", "secret", "blabla"); ManagerResponse response = manager.SendAction(config); //Console.WriteLine(response); } OriginateAction oc = new OriginateAction(); oc.Context = ORIGINATE_CONTEXT; oc.Priority = 1; oc.Channel = @"SIP/SOFTPHONE001"; oc.CallerId = "Hello"; oc.Exten = "9793616700"; oc.Timeout = ORIGINATE_TIMEOUT; ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); CommandAction ca = new CommandAction("Dial 9793616700,180,D(w8w3w2w3w6w8w7w3w8w7)"); ManagerResponse commandResponse = manager.SendAction(ca, ORIGINATE_TIMEOUT); Console.WriteLine("Command Response:"); Console.WriteLine(commandResponse); Console.WriteLine("Hello Press ENTER key to next test."); Console.ReadLine(); }