Exemple #1
0
        static void Main()
        {
            Console.WriteLine("Example STUN Server");

            ConfigureConsoleLog();

            // STUN servers need two separater end points to listen on.
            IPEndPoint primaryEndPoint   = new IPEndPoint(IPAddress.Any, 3478);
            IPEndPoint secondaryEndPoint = new IPEndPoint(IPAddress.Any, 3479);

            // Create the two STUN listeners and wire up the STUN server.
            STUNListener primarySTUNListener   = new STUNListener(primaryEndPoint);
            STUNListener secondarySTUNListener = new STUNListener(secondaryEndPoint);
            STUNServer   stunServer            = new STUNServer(primaryEndPoint, primarySTUNListener.Send, secondaryEndPoint, secondarySTUNListener.Send);

            primarySTUNListener.MessageReceived   += stunServer.STUNPrimaryReceived;
            secondarySTUNListener.MessageReceived += stunServer.STUNSecondaryReceived;

            // Optional. Provides verbose logs of STUN server activity.
            EnableVerboseLogs(stunServer);

            Console.WriteLine("STUN server successfully initialised.");

            Console.Write("press any key to exit...");
            Console.Read();

            primarySTUNListener.Close();
            secondarySTUNListener.Close();
            stunServer.Stop();
        }
Exemple #2
0
        public void Stop()
        {
            try
            {
                logger.Debug("SIP Proxy daemon stopping...");

                m_stop = true;
                m_stunClientMRE.Set();

                if (m_natKeepAliveRelay != null)
                {
                    logger.Debug("Stopping NAT Keep-Alive Relay.");
                    m_natKeepAliveRelay.Shutdown();
                }

                if (m_stunServer != null)
                {
                    logger.Debug("Stopping STUN server.");
                    m_stunServer.Stop();
                }

                if (m_silverlightPolicyServer != null)
                {
                    m_silverlightPolicyServer.Stop();
                }

                logger.Debug("Shutting down SIP Transport.");
                m_sipTransport.Shutdown();

                logger.Debug("SIP Proxy daemon stopped.");
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPProxyDaemon Stop. " + excp.Message);
            }
        }