private void HubConnection_StateChanged()

in TrayListener/MainWindow.xaml.cs [164:201]


        private void HubConnection_StateChanged(StateChange obj)
        {
            this.Dispatcher.Invoke(() =>
            {
                switch (obj.NewState)
                {
                    case ConnectionState.Reconnecting:
                        SetNotifyIcon("orange.ico");
                        tryingToReconnect = true;
                        MessageBox.Show("Your SignalR connection has failed; launching meetings will not function until the connection is restored. The application will try to reconnect automatically.", "Lost connection", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                        UpdateSignalRUIStatus("Reconnecting...");
                        break;
                    case ConnectionState.Connected:
                        SetNotifyIcon("green.ico");
                        UpdateSignalRUIStatus("Connected, listening");
                        tryingToReconnect = false;
                        break;
                    case ConnectionState.Connecting:
                        SetNotifyIcon("orange.ico");
                        UpdateSignalRUIStatus("Connecting...");
                        break;
                    case ConnectionState.Disconnected:
                        SetNotifyIcon("red.ico");
                        UpdateSignalRUIStatus("Disconnected");
                        if (!tryingToReconnect && reconnectDelay > reconnectDelayTimeout)
                        {
                            MessageBox.Show("Could not reconnect. Please verify your network connectivity and restart the application.", "Lost connection", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                        }
                        else
                        {
                            reconnectDelay = reconnectDelay * 2;
                            reconnectDelayRemaining = reconnectDelay;
                            QueueSignalRReconnect();
                        }
                        break;
                }
            });
        }