Example #1
0
 public static void Stop()
 {
     if (server != null)
     {
         server.Stop();
     }
 }
Example #2
0
        public void Dispose()
        {
            if (streaming_server != null)
            {
                streaming_server.Stop();
                streaming_server = null;
            }

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

            if (download_manager != null)
            {
                download_manager.Dispose();
                download_manager = null;
            }

            if (upload_manager != null)
            {
                upload_manager.Dispose();
                upload_manager = null;
            }

            if (container != null)
            {
                foreach (ContactSource source in container.Children)
                {
                    Log.DebugFormat("Disposing of ContactSource named {0}", source.Name);
                    source.Contact.ContactServicesChanged -= OnContactServicesChanged;
                    source.Dispose();
                }

                ServiceManager.SourceManager.RemoveSource(container, true);
                container = null;
            }

            if (locator != null)
            {
                locator.ConnectionStatusChanged -= OnConnectionStatusChanged;
                locator.Dispose();
                locator = null;
            }

            foreach (KeyValuePair <string, Connection> kv in conn_map)
            {
                if (kv.Value != null)
                {
                    kv.Value.Roster.RosterStateChanged -= OnRosterStateChanged;
                    kv.Value.Disconnected -= OnDisconnected;
                    kv.Value.Dispose();
                }
            }

            conn_map.Clear();
            source_map.Clear();

            TelepathyNotification notify = TelepathyNotification.Get;

            if (notify != null)
            {
                notify.Dispose();
            }
        }
Example #3
0
        private void BtnStartStopStream_Click(object sender, RoutedEventArgs e)
        {
            // A timer that will check the number of users connected to the server every 30 seconds.
            var timer = new DispatcherTimer();

            timer.Tick    += TimerTick;
            timer.Interval = new TimeSpan(0, 0, 30);

            if (BtnStartStopStream.Content.ToString() == UiConstants.StartStream)
            {
                try
                {
                    ConfigureUiAtServerStartup();

                    PrintInfo(UiConstants.ServerConfiguration);

                    var ipAddress = IPAddress.Parse(TbIpAddress.Text);
                    int port      = int.Parse(TbPort.Text);
                    var fps       = GetFpsFromComboBox(CbFps.Text);

                    CheckSocket(ipAddress, port);

                    TbUrl.Text = $"http://{ipAddress}:{port}";

                    PrintInfo(UiConstants.StartingServer);

                    StartStreamingServer(ipAddress, port, fps);

                    PrintInfo(UiConstants.ServerIsStarted + TbUrl.Text + UiConstants.NewLine);

                    timer.Start();

                    Settings.Default["IpAddress"] = TbIpAddress.Text;
                    Settings.Default["Port"]      = TbPort.Text;
                    Settings.Default.Save();
                }
                catch (FormatException)
                {
                    MessageBox.Show(UiConstants.PortOrIpErrorMessage, UiConstants.ErrorTitle,
                                    MessageBoxButton.OK, MessageBoxImage.Error);

                    ConfigureUiWhenServerStops();
                    PrintInfo(UiConstants.ServerStop);
                }
                catch (SocketException)
                {
                    MessageBox.Show(UiConstants.IpAddressErrorMessage, UiConstants.ErrorTitle,
                                    MessageBoxButton.OK, MessageBoxImage.Error);

                    ConfigureUiWhenServerStops();
                    PrintInfo(UiConstants.ServerStop);
                }
            }
            else
            {
                PrintInfo(UiConstants.ServerStop);

                _streamingServer.Stop();
                timer.Stop();

                PrintInfo(UiConstants.ServerIsStopped);

                ConfigureUiWhenServerStops();
            }
        }
Example #4
0
 private void MainWindow_OnClosed(object sender, EventArgs e)
 {
     _streamingServer?.Stop();
 }