Пример #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Get list of networks
            try
            {
                var networks = Network.GetLocalAddresses();
                comboNetworks.ItemsSource = networks;

                comboNetworks.SelectedIndex = 0;

                string selectedHost = comboNetworks.SelectedValue.ToString();
                new Thread(() =>
                {
                    Server.Host = selectedHost;
                    Server.Start();

                    BroadcastServer.StartBroadcast(IPAddress.Parse(selectedHost));
                }).Start();

                CheckForUpdates();

                WindowRendered = true;
            } catch (Exception ex)
            {
                System.Windows.MessageBox.Show("We couldn't detect your primary network! Ensure you have a network connection and try again. (" + ex.Message + ")",
                                               "Network error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close(); // Close the window
            }
        }
Пример #2
0
        private void RestartServer(string ip)
        {
            StopServer();

            new Thread(() =>
            {
                BroadcastServer.StartBroadcast(IPAddress.Parse(ip));

                Server.Host = ip;
                Server.Start();
            }).Start();
        }