.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to build your C# Command Line Caller

Posted By:Evan Miller       Posted Date: July 05, 2011    Points: 200    Category: C#    URL: http://www.dotnetspark.com  

I would like to share my experiences with fellow developers who are also interested in voip technology and all the stuffs connecting to it. This article is specified about building a command line caller in C#.

I'm writing this article because lately I've started thinking about how we live in the world of fancy surfaces. Everywhere you look there are these over-designed, fussy surfaces under which it is hard to find the real content, the real functions, if there are any. I'm an "old-fashioned" developer, and maybe there are more of like me who prefer functionality over appearance. Those are who really could appreciate my article beacuse it is about building a simple command line caller, with the help of a software development kit. Beginner developers can also utilize this guide if they don't want to bother with creating a graphical user interface for their applications but using a simple command to make phonecalls. At the end of this article I will mention a site that I've used as the source of my article to present my work. There you can download the sample program I'm writing about. This way you can follow my train of thoughts easier.

I don't want to repeat what the site says about the process of installing and configurating this sdk example, so let's skip to the build-up of the source code in which you are probably more interested.

After starting the program check if the phone number you want to call was given as an argument. If there is no phone number provided as argument the user gets a notification. The following code section demonstrate this case:

  1. if (args.Length != 1)  

  2. {  

  3.     Console.WriteLine("Parameter is not valid!");  

  4.     Console.ReadLine();  

  5.     return;  

  6.     }  

In case the argumentum is correct, the initialization block comes:

  1. static void InitializeSoftPhone()  

  2. {  

  3.     /* Create a real or a test softphone... 

  4.      * */  

  5.     softPhone = SoftPhoneFactory.CreateSoftPhone(  

  6.         GetLocalIP().ToString(), 5700, 5750, 5700);  


  8.     /* Set the SIP Account settings.. 

  9.      * */  

  10.     SIPAccount acc = new SIPAccount(  

  11.        registrationRequired: true,  

  12.        displayName: "oz888",  

  13.        userName: "oz888",  

  14.        registerName: "oz888",  

  15.        registerPassword: "oz888",  

  16.        domainServerHost: "",  

  17.        domainServerPort: 5060  

  18.    );  


  20.     /* Create a phone line using the softphone. 

  21.      * */  

  22.     line = softPhone.CreatePhoneLine(acc);  



  25.     /* Create event handler for the phone line. 

  26.      * */  

  27.     line.PhoneLineInformation += Line_PhoneLineInformation;  


  29.     softPhone.RegisterPhoneLine(line);  


  31.     activeAudioCallListener = ActiveAudio.Instance;  

  32.     mixer = new AudioMixer();  

  33.     mixer.Add(activeAudioCallListener);  

  34. }  

Create an instance of the phone via the 'softPhone' object and give the IP address of your computer and the port domain that can be used by the phone. Finally specify the port, at which the SIM messages arriving from the PBX are listened, as the last parameter.

Create a phoneLine with a SIP account that can be the user account of your corporate SIP PBX or a free SIP provider account. To display the status of the created telephone line, sign up to its '
phoneLine.PhoneLineInformation' event.

When these things are done you only need to register the created '
phoneLine' to the 'softPhone'. In this example only one telephone line is registered but of course multiple telephone line registration is also available.

After these steps only the call needs to be started.

  1. SoftPhone.RegisterPhoneLine(line);  

The code finally includes that section where you can manage the event when the called party picked up the phone and the voice communication started.

  1. static void Line_PhoneLineInformation(object sender, VoIPEventArgs e)  

  2. {  

  3.     Console.WriteLine(e.Item);  

  4.     IPhoneLine line = sender as IPhoneLine;  

  5.     if (sender == null)  

  6.         return;  


  8.     if (e.Item != PhoneLineInformation.NoRegNeeded &&   

  9.         e.Item != PhoneLineInformation.RegistrationSucceded)  

  10.         return;  


  12.     /* Create phone call, if the line was registered successfully. 

  13.      * */  

  14.     Call = softPhone.CreateCallObject(line, phoneNumber);  


  16.     Call.CallStateChanged += Call_CallStateChanged;  

  17.     Call.Start();  

  18. }  

I hope my presentation was understandable for everyone, I didn't want to overexplain anything. If you want to see it in practice, or you simply want to know more, you should visit this site: http://www.voip-sip-sdk.com/p_163-how-to-use-the-c-sip-softphone-source-implementation-of-ozeki-voip-sip-sdk-for-command-line-caller-voip.html

Thanks for your attention.

 Subscribe to Articles


Further Readings:

Author: Gowthammanju         Company URL: http://www.dotnetspark.com
Posted Date: July 05, 2011

Hey it is copied content of this url as


just type ur innovative thoughts with that concept

please avoid coping!
Author: Evan Miller         Company URL: http://www.dotnetspark.com
Posted Date: July 06, 2011

Yes, it is the same article, as both was published by me. I usually visit more than just one computer related site. I would like to share my thoughts with as many people as possible.

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend