Exemple #1
0
        private void Stop2()
        {
            try
            {
                if (turnServer != null)
                {
                    turnServer.Stop();
                    turnServer = null;
                }

                if (wcfService != null)
                {
                    wcfService.NewConfigurationSetted -= WcfService_NewConfigurationSetted;
                    wcfService.Dispose();
                    wcfService = null;
                }

                AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
            }
            catch (Exception ex)
            {
                WriteLogEntry("Error ocurs while stoping: " + ex.ToString(), EventLogEntryType.Error);
            }
        }
Exemple #2
0
        private void Start2()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            settings = new Settings(GetAppPath(Settings.SettingsFileName));
            settings.Load();

            try
            {
                string wcfServiceUri = @"net.tcp://*****:*****@"OfficeSIP.pfx"),
                    ServiceUri = wcfServiceUri,
                    ServiceSettings = settings,
                };

                wcfService.NewConfigurationSetted += WcfService_NewConfigurationSetted;

                wcfService.Start();

                WriteLogEntry("WCF Service started.", EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                WriteLogEntry("Failed to start WCF service: " + ex.ToString(), EventLogEntryType.Error);
            }

            try
            {
                WriteLogEntry(
                    String.Format("Starting TurnServer\r\nTurn UDP Port: {0}\r\nTurn TCP Port: {1}\r\nTurn TLS Port: {2}\r\nPublic IP and Ports Range: {3}:{4}-{5}\r\nRealm: {6}",
                    settings.TurnUdpPort, settings.TurnTcpPort, settings.TurnTlsPort,
                    settings.PublicIp, settings.MinPort, settings.MaxPort, settings.Realm),
                    EventLogEntryType.Information);

                turnServer = new Turn.Server.TurnServer(this)
                {
                    TurnUdpPort = settings.TurnUdpPort,
                    TurnTcpPort = settings.TurnTcpPort,
                    TurnPseudoTlsPort = settings.TurnTlsPort,
                    PublicIp = settings.PublicIp,
                    RealIp = settings.RealIp,
                    MinPort = settings.MinPort,
                    MaxPort = settings.MaxPort,
                    Authentificater = new Turn.Server.Authentificater()
                    {
                        Realm = settings.Realm,
                        Key1 = settings.Key1,
                        Key2 = settings.Key2,
                    },
                };

                turnServer.Start();

                WriteLogEntry("TurnServer started.", EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                WriteLogEntry("Failed to start TurnServer: " + ex.ToString(), EventLogEntryType.Error);

                turnServer.Stop();
                turnServer = null;
            }
        }
Exemple #3
0
        private void Start2()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            settings = new Settings(GetAppPath(Settings.SettingsFileName));
            settings.Load();

            try
            {
                string wcfServiceUri = @"net.tcp://*****:*****@"OfficeSIP.pfx"),
                    ServiceUri      = wcfServiceUri,
                    ServiceSettings = settings,
                };

                wcfService.NewConfigurationSetted += WcfService_NewConfigurationSetted;

                wcfService.Start();

                WriteLogEntry("WCF Service started.", EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                WriteLogEntry("Failed to start WCF service: " + ex.ToString(), EventLogEntryType.Error);
            }

            try
            {
                WriteLogEntry(
                    String.Format("Starting TurnServer\r\nTurn UDP Port: {0}\r\nTurn TCP Port: {1}\r\nTurn TLS Port: {2}\r\nPublic IP and Ports Range: {3}:{4}-{5}\r\nRealm: {6}",
                                  settings.TurnUdpPort, settings.TurnTcpPort, settings.TurnTlsPort,
                                  settings.PublicIp, settings.MinPort, settings.MaxPort, settings.Realm),
                    EventLogEntryType.Information);

                turnServer = new Turn.Server.TurnServer(this)
                {
                    TurnUdpPort       = settings.TurnUdpPort,
                    TurnTcpPort       = settings.TurnTcpPort,
                    TurnPseudoTlsPort = settings.TurnTlsPort,
                    PublicIp          = settings.PublicIp,
                    RealIp            = settings.RealIp,
                    MinPort           = settings.MinPort,
                    MaxPort           = settings.MaxPort,
                    Authentificater   = new Turn.Server.Authentificater()
                    {
                        Realm = settings.Realm,
                        Key1  = settings.Key1,
                        Key2  = settings.Key2,
                    },
                };

                turnServer.Start();

                WriteLogEntry("TurnServer started.", EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                WriteLogEntry("Failed to start TurnServer: " + ex.ToString(), EventLogEntryType.Error);

                turnServer.Stop();
                turnServer = null;
            }
        }