Exemple #1
0
        public async void StartServer()
        {
            try
            {
                await _ws.StartServer(_bpFactory, 1, (int)_port, _loopback, _secure, _hostname);

                ConnToggleButton.Content   = "Stop";
                SecureCheckBox.IsEnabled   = false;
                PortTextBox.IsEnabled      = false;
                LoopbackCheckBox.IsEnabled = false;
                _connUrls.Clear();
                _connUrls.Add(new ConnUrlData(_secure, "localhost", _port));

                if (!_loopback)
                {
                    foreach (var network in NetworkInterface.GetAllNetworkInterfaces())
                    {
                        foreach (IPAddressInformation address in network.GetIPProperties().UnicastAddresses)
                        {
                            if (address.Address.AddressFamily == AddressFamily.InterNetwork &&
                                !IPAddress.IsLoopback(address.Address))
                            {
                                _connUrls.Add(new ConnUrlData(_secure, address.Address.ToString(), _port));
                            }
                        }
                    }
                }

                ConnStatus.Content         = "(Not Connected)";
                DisconnectButton.IsEnabled = false;
                ConnInfo.IsEnabled         = true;

                // We've brought the server up, clear the error.
                ClearLastError();
            }
            catch (SocketException e)
            {
                _currentExceptionMessage = e.Message;
                _log.LogException(e, true, _currentExceptionMessage);
            }
            catch (CryptographicException e)
            {
                _currentExceptionMessage =
                    "Cannot start server with SSL. Try turning off SSL. The server can still be used with ScriptPlayer, but not web applications. If you need SSL, contact B******g Developers for support (see About Tab).";
                _log.LogException(e, true, _currentExceptionMessage);
            }
        }
        public void StartServer()
        {
            try
            {
                _ws.StartServer(_bpFactory, (int)_port, _loopback, _secure, _hostname);
                ConnToggleButton.Content   = "Stop";
                SecureCheckBox.IsEnabled   = false;
                PortTextBox.IsEnabled      = false;
                LoopbackCheckBox.IsEnabled = false;
                _connUrls.Clear();
                _connUrls.Add(new ConnUrlData(_secure, "localhost", _port));

                if (!_loopback)
                {
                    foreach (var network in NetworkInterface.GetAllNetworkInterfaces())
                    {
                        foreach (IPAddressInformation address in network.GetIPProperties().UnicastAddresses)
                        {
                            if (address.Address.AddressFamily == AddressFamily.InterNetwork &&
                                !IPAddress.IsLoopback(address.Address))
                            {
                                _connUrls.Add(new ConnUrlData(_secure, address.Address.ToString(), _port));
                            }
                        }
                    }
                }

                ConnStatus.Content         = "(Not Connected)";
                DisconnectButton.IsEnabled = false;
                ConnInfo.Visibility        = Visibility.Visible;
            }
            catch (SocketException e)
            {
                _log.LogException(e, true, e.Message);
            }
            catch (CryptographicException e)
            {
                _log.LogException(e, true, e.Message);
            }
        }