Ozeki VoIP SDK - Product Guide
Developers Guide
How to reject an incoming call
Explanation
Prerequisities
![]() |
Download: | SoftphoneExample.zip |
Ozeki VoIP SIP SDK offers reliable background and functionalities for developing a decent softphone. Such a noted function is the ability to reject an incoming call. Please find below the source codes that help you achieve call rejection with Ozeki SIP SDK.
Introduction
In any kind of communication there is a need for the ability of choosing between accepting or rejecting a call. The VoIP communication programs also need to support call rejection as an elementary function (Figure 1).
Call rejection basically means that you do not want to communicate with the caller either because of the person or because you have other duties to fulfill. In this case you can reject the call by sending a message to the caller about the rejection. This is usually implemented in a method and the operation itself is as simple as pressing the right button on the graphical user interface (GUI).
Figure 1 - Rejecting an incoming call
The following program code uses the background support of Ozeki VoIP SIP SDK, therefore you will need to download and install the SDK on your computer before starting to use the program code. You will also need to have Visual Studio 2010 or compatible IDE and .NET Framework installed on your system, as the program code below is written in C# language.
Implementing Call Rejection with Ozeki VoIP SIP SDK
As Ozeki VoIP SIP SDK provides all the background support for VoIP calls, you only need to implement some basic functionality for your softphone application.
If you want to reject an incoming call, first you need to realize that there is an incoming call in progress. For this purpose you can use the following code snippet shown in Code 1.
private void softPhone_IncomingCall(object sender, VoIPEventArgs<IPhoneCall> e)
{
InvokeGUIThread(() =>
{
RegistrationState.Text = "Incoming call";
DialedNumber.Text = String.Format("from {0}", e.Item.DialInfo);
call = e.Item;
WireUpCallEvents();
inComingCall = true;
});
}
Code 1 - This code runs in case of an incoming call
When you realize that there is an incoming call, you can decide to accept or reject it. These actions can be made by pressing a button on the softphone GUI. If you want to reject the call you will need to press the Hang Up button.
Code 2 shows the event handler method for the Hang Up button's Click event that will run when you press the button. As it is seen the method is really simple. As the button has double functionality, the whole method needs a check for an existing call. If there is an established call, pressing the Hang Up button will end it.
The call rejection itself is only a method call as the actual functionality is implemented in Ozeki VoIP SIP SDK. The only thing that matters here that you set the right logical expression for the check. You need to reject a call when there is an incoming call and that call is in ringing status that means it was not accepted yet.
private void HangUp_Click(object sender, EventArgs e)
{
if (call != null)
{
if (inComingCall && call.CallState == CallState.Ringing)
call.Reject();
else
call.HangUp();
inComingCall = false;
call = null;
}
DialedNumber.Text = string.Empty;
}
Code 2 - The event handler for the Hang Up button
As you can see, VoIP solutions get an extraordinary background support from Ozeki VoIP SIP SDK. Call rejection is only one of the functionalities that can be performed easily with Ozeki VoIP SIP SDK. If you want your softphone work properly with the less code writing, you need to use Ozeki VoIP SIP SDK.
This article explores all the knowledge about rejecting an incoming call with Ozeki VoIP SIP SDK that can help you fulfill your goals. If you have read through this page carefully, you already have all the knowledge you need to start your own solution.
If you have any questions or need assistance, please contact us at info@voip-sip-sdk.com
You can select a suitable Ozeki VoIP SIP SDK license for developing your softphone with call reject on Pricing and licensing information page >>>
Related Pages
- To integrate Ozeki VoIP SIP SDK quickly, please check Quick start guide
- Download Ozeki VoIP SIP SDK form the Ozeki VoIP SIP SDK download page
- You can find licensing information of Ozeki VoIP SIP SDK on Pricing and licensing information page
| Operating system: | Windows 8, Windows 7, Vista, 200x, XP |
| Development environment: | Visual Studio 2010 (Recommended), Visual Studio 2008, Visual Studio 2005 |
| Programming language: | C#.NET |
| Supported .NET framework: | .NET Framework 4.5, .NET Framework 4.0, .NET Framework 3.5 SP1 |
| Software development kit: | OZEKI VoIP SIP SDK (Download) |
| VoIP connection: | 1 SIP account |
| System memory: | 512 MB+ |
| Free disk space: | 100 MB+ |
INTERMEDIATE
VoIP technology walkthrough
Softphone development
Webphone development
Mobile development
Voice recording
GETTING AROUND
Sitemap
Search the manual
API documentation
FAQ
Appendix


