Ejemplo n.º 1
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">Arguments not needed</param>
        static void Main(string[] args)
        {
            // Create transport object that will listen on the following port on the best guessed local address
            Random        rnd            = new Random();
            int           port           = rnd.Next(5090, 6090);
            TransportInfo localTransport = CreateTransport("172.27.0.130", port);
            // Can also specify an IP if you know the IP to be used.
            //TransportInfo localTransport = CreateTransport("192.168.20.28", 8989);

            // Create an object of your SIP handling logic with the created transport
            SIPApp app = new SIPApp(localTransport);

            // Create a SIP stack with the proxy address if needed
            SIPStack stack = CreateStack(app, "alice", "172.30.0.161", 5060);

            // Register with the specified user URI
            app.Register("sip:[email protected]");

            while (true)
            {
                app.Invite("sip:[email protected]");
            }

            // Simple pause so you can test each function / watch the SIP signalling
            Console.ReadKey();
            app.Invite("*****@*****.**");
            // Simple pause so you can test each function / watch the SIP signalling
            Console.ReadKey();

            // End the current call (presuming it was accepted)
            app.EndCurrentCall();
            // Send an example IM
            app.Message("*****@*****.**", "Hello, this is alice testing the SIP library");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a SIP stack.
        /// </summary>
        /// <param name="app">The associated sip application.</param>
        /// <param name="username">The username representing this SIP endpoint.</param>
        /// <param name="proxyIp">The proxy ip if any.</param>
        /// <param name="proxyPort">The proxy port if any.</param>
        /// <returns>SIPStack.</returns>
        public static SIPStack CreateStack(SIPApp app, string username, string proxyIp = null, int proxyPort = -1)
        {
            SIPStack myStack = new SIPStack(app)
            {
                Uri = { User = username }
            };

            if (proxyIp != null)
            {
                myStack.ProxyHost = proxyIp;
                myStack.ProxyPort = (proxyPort == -1) ? 5060 : proxyPort;
            }
            return(myStack);
        }