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


Top 5 Contributors of the Month
david stephan

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

 Subscribe to Articles

How to build your own C# Callback Form

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

This article is about the easiest way of creating a C# Callback Form by yourself.
 

This article is inspired to present the easiest way of building your own Callback Form in C#. I've found this software development kit while doing some research in the subject for a friend. He has lately started his small enterprise and wanted to get connected with the customers the easiest way. Since the business is quite small and he's a modest man who likes to make things in a personal way he doesn't need an autodialer for instance to get in touch with thousands of people and repeat them the same impersonal commercial message. But he would like to be available for the customers in 24/7. He's already got a website, and my idea was to place a callback form in it. In this way, website visitors can fill in the query form, provide a summary of the products they are interested in and enter their phone number. When the Callback form is filled in, the SDK calls the intended operator (or, you know... you) and the person who needs information at the same time. If both calls are accepted, then the SDK connects the two lines. In this way, the operator and the person who needs information can talk to each other. My friend likes this, because only serious customers call him, and personal conversations are more convincing than listening to a machine.

The downloadable sample program and the configuration guide can be found on the site I've used as the source of my article: http://www.voip-sip-sdk.com/p_159-how-to-create-a-callback-form-using-the-ozeki-c-sip-voip-softphone-source-voip.html

Now, we only take a look at the code of initiating a call.

 

For connecting two calls, it is required to establish two successful calls with the two given telephone numbers (The call is successful if it is accepted by the called party). First, the operator is called and if the call is successful, the customer is also called. When the two calls are connected the audio data are transferred between the two participants by the sample program.

 

Initiation of calls is made in a set time instant. I make the examination of this time instant with the help of the timer offered by .Net Framework. This timer examines in every seconds if it is the time for making the call. When it is time for call, the BeginCall(bool IsCustomerCall) method is called. This method dials the operator or the customer according to the value of the bool parameter. Meanwhile, it informs us about this procedure on the interface.

1.    private void BeginCall(bool IsCustomerCall)  

2.    {  

3.        if (IsCustomerCall && !String.IsNullOrWhiteSpace(textBoxCallbackPhone.Text))  

4.        {  

5.            callcustumer =   

6.                softPhone.CreateCallObject(phoneLine, textBoxCallbackPhone.Text);  

7.            WireUpCallEvents(callcustumer);  

8.            InvokeGUIThread(() =>  

9.            {  

10.                                   listBoxEvents.Items.Add(  

11.                                       String.Format("{0} call starts.", callcustumer));  

12.                               });  

13.                               callcustumer.Start();  

14.                           }  

15.                           else  

16.                           {  

17.                               if (string.IsNullOrWhiteSpace(textBoxOperator.Text))  

18.                                   return;  

19.                         

20.                               if (phoneLineInformation != PhoneLineInformation.RegistrationSucceded &&   

21.                                   phoneLineInformation != PhoneLineInformation.NoRegNeeded)  

22.                               {  

23.                                   MessageBox.Show("Phone line state is not valid!");  

24.                                   return;  

25.                               }  

26.                         

27.                               calloperator = softPhone.CreateCallObject(phoneLine, textBoxOperator.Text);  

28.                               WireUpCallEvents(calloperator);  

29.                               InvokeGUIThread(() =>  

30.                               {  

31.                                   listBoxEvents.Items.Add(String.Format("{0} call starts.", calloperator));  

32.                               });  

33.                               calloperator.Start();  

34.                           }  

35.                       }  

To initiate a call, you need to create an IPhoneCall object representing a call by using 'softPhone.Call' method and its parameters. The first parameter is the phone line via which you wish to initiate the call. The second parameter is the phone number to be called. To make a successful call, you need to subscribe to specific events. Therefore, the audio data and DTMF signals arriving from the remote end, or the changes of the call status can be processed efficiently. I made the subscription in the sample program as follows:

1.    private void WireUpCallEvents(IPhoneCall call)  

2.    {  

3.        call.CallStateChanged += new EventHandler>(call_CallStateChanged);  

4.        call.MediaDataReceived += new EventHandler>(call_MediaDataReceived);  

5.        call.DtmfReceived += new EventHandler>>(call_DtmfReceived);  

6.        call.CallErrorOccured += new EventHandler(call_CallErrorOccured);  

7.    }  

CallStateChanged:
This event is for demonstrating the changes in the call status. 

MediaDataRecived:
The audio data from the remote telephone device arrives via this event.

DtmfReceived:
This event is responsible for processing DTMF signals that are arrived from the remote end.

This is only a small sneak peak at the coding, you can find more on the site mentioned above. If you're interested in this subject, you definitely should visit it.


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

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