This project is read-only.

Quick Start

1. Create a new C# Console application in Visual Studio,
2. Use the Nuget Package Manager and install the SIPSorcery package,
3. Cut and paste in the code below to send a test INVITE request to your SIP phone or softphone.

// ============================================================================
// Description:
// This program provides a minimal example of how to use the SIP Sorcery SIP stack
// to initiate a call to an external user agent. The example sets up the SIP transport
// and then fires off an empty INVITE request to the destination SIP user agent. 
// No media is negotiated and no incoming SIP requests are handled.
// Author(s):
// Aaron Clauson
// License: 
// This software is licensed under the BSD License

using System;
using System.Net;
using SIPSorcery.SIP;
using SIPSorcery.SIP.App;
using SIPSorcery.Sys;

namespace SIPSorcery.Test
    class Program
        // The SIP stack internals will bubble log messages up. use this delegate to spit them out to the console.
        private static SIPMonitorLogDelegate _logDelegate = (evt) => { if (evt is SIPMonitorConsoleEvent) { Console.WriteLine(((SIPMonitorConsoleEvent)evt).ToConsoleString("*")); } };

        static void Main(string[] args)
                Console.WriteLine("SIPSorcery Example:");

                // Set up the SIP transport infrastructure.
                SIPTransport sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine());
                SIPUDPChannel udpChannel = new SIPUDPChannel(new IPEndPoint(IPAddress.Any, 5060));

                // Create a SIP user agent client that can be used to initiate calls to external SIP devices and place a call.
                SIPClientUserAgent uac = new SIPClientUserAgent(sipTransport, null, null, null, _logDelegate);
                SIPCallDescriptor callDescriptor = new SIPCallDescriptor("anonymous", null, "sip:anon@", "<sip:anon@>", null, null, null, null, SIPCallDirection.Out, "application/sdp", null, null);

                Console.WriteLine("Hit any key to cancel call...");

            catch(Exception excp)
                Console.WriteLine("Exception Main. " + excp);
                Console.Write("press any key to exit...");

Last edited Nov 21, 2014 at 10:56 AM by aaronc, version 1


No comments yet.