info@voip-sip-sdk.com Tel.: 00 36 52 532 731
Ozeki C# VoIP SDK - Sample code for Ozeki VoIP SIP SDK

Sample code for Ozeki VOIP SIP SDK:

Use this sample code to explore the excellent functions of Ozeki VoIP SIP SDK! Try how simple to integrate this SDK into your application...


using System;

namespace CodeSample
{
    class Program
    {

         static Ozeki.VoIP.SDK.ISoftPhone softPhone;

         static void Main(string[] args)
         {
             /* Create a real or a test softphone...
              * */
             softPhone = Ozeki.VoIP.SDK.SoftPhoneFactory.CreateSoftPhone(Ozeki.VoIP.SDK.SoftPhoneFactory.GetLocalIP(),
                       5700, 5750, 5700);

             /* Set the SIP Account settings..
              * */
             Ozeki.VoIP.SIPAccount acc = new Ozeki.VoIP.SIPAccount(
                 registrationRequired: true,
                 displayName: "oz875",
                 userName: "oz875",
                 registerName: "oz875",
                 registerPassword: "oz875",
                 domainServerHost: "192.168.112.100",
                 domainServerPort: 5060
             );

             /* Create a phone line using the softphone.
              * */
             Ozeki.VoIP.IPhoneLine phoneLine = softPhone.CreatePhoneLine(acc);

             /* Create event handler for the phone line.
              * */
             phoneLine.PhoneLineStateChanged += new EventHandler<Ozeki.VoIP.VoIPEventArgs<Ozeki.VoIP.PhoneLineState>>(phoneLine_PhoneLineStateChanged);

             /* Register the phone line on softphone.
              * */
             softPhone.RegisterPhoneLine(phoneLine);

             Console.ReadLine();
         }

        /// <summary>
        /// Event handler method
        /// </summary>
        /// <param name="sender">The phone line</param>
        /// <param name="e">The information about the phone line state</param>
        static void  phoneLine_PhoneLineStateChanged(object sender, Ozeki.VoIP.VoIPEventArgs<Ozeki.VoIP.PhoneLineState> e)
        {
                 Ozeki.VoIP.IPhoneLine Line = sender as Ozeki.VoIP.IPhoneLine;

                     if (sender == null)
                         return;

                     if (e.Item != Ozeki.VoIP.PhoneLineState.NoRegNeeded &&
                        e.Item != Ozeki.VoIP.PhoneLineState.RegistrationSucceeded)
                         return;

                     /* Create phone call, if the line was registered successfully.
                      * */
                     call = softPhone.CreateCallObject(Line, "873");
                     call.Start();
        }

        /// <summary>
        /// The call object
        /// </summary>
        private static Ozeki.VoIP.IPhoneCall call;
    }
}


Related pages:

Start using Ozeki VoIP SIP SDK in seconds - Quick Start Guide

Learn the excellent functions of the SDK...

Request a quotation!