How to manage multiple phone lines at the same time
Download: | multiple-phone-lines.zip |
This article is a detailed guide about how to manage multiple phone lines when you use Ozeki VoIP SIP SDK. To use this example, you need to have Ozeki VoIP SIP SDK installed, and a reference to ozeki.dll should be added to your visual studio project. It's also recommended to visit the How to register to a SIP PBX article before you begin to study this functionality.
What is multiple phone lines mean? When is it needed?
Advanced VoIP communication has to include the support of multiple phone lines. (Figure 1) It's main advantage is that you can register to more than one VoIP Provider and you can even decide which one of these VoIP Providers you wish to use for the given calls. For instance, if a company has offices on different locations, at any of these locations, it will be possible to register then make calls as if you were at any of the different offices.
How to implement multiple phone lines using C#?
The phone line is directly connected to the SIP account you register to the PBX system. You can register more SIP accounts in your PBX and change them during the softphone runtime. In this case you can choose which line you wish to use for phone calls.
This example program handles two SIP accounts, therefore two phone lines can be used in it. The softphone function is similar in this example to the basic softphones, but there are some differences. The Softphone class stores the two registered phone line objects in phoneLine and phoneLineTwo properties.
Multiple phone line example in C#
using System; using System.Threading; using Ozeki.VoIP; namespace Multiple_phone_lines { class Program { static ISoftPhone softphone; // softphone object static IPhoneLine phoneLine; // phoneline object static IPhoneLine phoneLineTwo; // second phoneline object private static void Main(string[] args) { // Create a softphone object with RTP port range 5000-10000 softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000); // SIP account registration data, (supplied by your VoIP service provider) var registrationRequired = true; var userName = "858"; var displayName = "858"; var authenticationId = "858"; var registerPassword = "858"; var domainHost = "192.168.115.100"; var domainPort = 5060; // Second SIP account registration data, (supplied by your VoIP service provider) var registrationRequiredTwo = true; var authenticationIdTwo = "859"; var userNameTwo = "859"; var displayNameTwo = "859"; var registerPasswordTwo = "859"; var domainHostTwo = "192.168.115.100"; var domainPortTwo = 5060; var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort); var accountTwo = new SIPAccount(registrationRequiredTwo, displayNameTwo, userNameTwo, authenticationIdTwo, registerPasswordTwo, domainHostTwo, domainPortTwo); // Send SIP regitration request RegisterAccount(phoneLine, account); RegisterAccount(phoneLineTwo, accountTwo); // Prevents the termination of the application while (true) Thread.Sleep(50); } static void RegisterAccount(IPhoneLine phoneLine, SIPAccount account) { try { phoneLine = softphone.CreatePhoneLine(account); phoneLine.RegistrationStateChanged += line_RegStateChanged; softphone.RegisterPhoneLine(phoneLine); } catch (Exception ex) { Console.WriteLine("Error during SIP registration: " + ex); } } static void line_RegStateChanged(object sender, RegistrationStateChangedArgs e) { if (e.State == RegState.NotRegistered || e.State == RegState.Error) Console.WriteLine("Registration failed!"); if (e.State == RegState.RegistrationSucceeded) { Console.WriteLine("Registration succeeded - Online!"); } } } }
Related Pages
More information
- How to build a softphone voip sip client
- Register to SIP PBX
- Voip softphone development
- How to encrypt voip sip calls with sip encryption
- How to encrypt voip sip calls with rtp encryption
- How to ring a sip extension csharp example for sip invite
- How to make a sip voice call using csharp
- Voip multiple phone lines
- How to send stream of voice data into call using csharp microphone
- How to receive voice from SIP voice call using csharp speaker
- How to make conference voice call using voip sip
- How to play an mp3 file into a voice call using csharp
- How to convert text to speech and play that into a call using csharp
- How to use Microsoft Speech Platform 11 for TTS and STT
- How to record voip sip voice call
- How to accept incoming call using csharp
- How to reject incoming call using csharp
- How to read Headset buttons using Bluetooth
- How to implement auto answer using csharp
- How to recognize incoming voice using speech to text conversion
- Voip forward call
- Voip blind transfer
- Voip attended transfer
- Voip do not disturb
- Voip call hold
- SIP Message Waiting Indication
- Voip DTMF signaling
- How to work with sip and sdp in voip sip calls
- How to work with rtp in voip sip calls
- How to make voip video calls in csharp
- Voip video codec
- Shows how to use SpeechToText Google API
- How to convert Text to Speech using C# and Google
- Azure Text-to-Speech