How to Originate Call/hangup

Jul 3, 2013 at 10:46 PM
Would someone please show me a code how to make a call using line 111 and hangup in c# ?
Jul 3, 2013 at 10:53 PM
Please see the Call Originate example in the test project for initiating calls from AsterNET.
Jul 4, 2013 at 12:50 PM
Thanks for your reply. I went through asterisk.Test and asterisk.winform as you suggested. But yet if you just show me a line of code for call generating using line 111, My understanding of the code would be much better, besides it would help others as well as there is no documentation available. Hope you'd help us out on this.
Jul 4, 2013 at 1:11 PM
I assume by "line 111" you mean you want to call from extension 111 to another destination. If so, see the sample below, assuming the destination of the call (i.e. who's being called) is 112 (as an example).

Calls are placed using the OriginateAction class, and passed as a param into SendAction method of ManagerConnnection.
            OriginateAction oc = new OriginateAction();
            oc.Context = "default";  // Contact to drop into
            oc.Priority = 1;             // Dialplan Priority
            oc.Exten = "112";         // Who's being called (destination)
            oc.CallerId = "111";      // Called ID
            oc.Channel = "SIP/111"; // The phone the call should be made from or 'Originated As' (source)
            oc.Timeout = 30000;     // 30 second timeout
            ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout);
This is a modified example from Program.cs, Asterisk.NET.Text, line 175.
Jul 4, 2013 at 2:15 PM
Thank you very much...Appreciate it...
Jul 4, 2013 at 3:18 PM
Edited Jul 4, 2013 at 3:19 PM
Success (Somewhat). After studying your code I understand the structure better. Thank you for that. My code does connect and call the 'Originated As' source (1005). But after I pick up program should call Ext 1006 but it simply disconnect. I am posting my code...if you do have time would you please point out where I am wrong?..
private void buttonRegister_Click(object sender, EventArgs e)
            var originateAction = new OriginateAction();
            var originateResponse = new ManagerResponse();

            originateAction.Channel = "SIP/1005"; 
            originateAction.CallerId = "1005";
            originateAction.Context = "from-internal"; 
            originateAction.Exten = "1006";
            originateAction.Application = "Dial";
            originateAction.Priority = 1;
            originateAction.Timeout = 30000;
            originateAction.Async = true;


            originateResponse = asteriskManager.SendAction(originateAction, originateAction.Timeout);
Jul 4, 2013 at 4:32 PM
You don't need to do dial!

I assume that in "from-internal" you have an extension 1006 with prio 1 (something like Dial(SIP/1006) ) that should be good enough. Try removing Dial if you do have an extension 1006.
Jul 4, 2013 at 5:27 PM
That was it!! Thanks a million.