Exemple #1
0
        private void SessionOnConnectionStateChanged(object sender, ConnectionStateChangedEventArgs e)
        {
            using (Trace.Main.scope())
            {
                try
                {
                    if (e.State == ConnectionState.Up)
                    {
                        Trace.Main.always("Reinitializing!");
                        Initialize(_session, _interactionSelector);
                    }

                    // Clean up
                    if (e.State != ConnectionState.Up)
                    {
                        // Because Icelib cannot be trusted not to throw bizarre exceptions, supress errors from stopwatching
                        try
                        {
                            if (_customNotification != null && _customNotification.IsWatching())
                            {
                                _customNotification.StopWatching();
                                _customNotification.CustomNotificationReceived -= OnCustomNotificationReceived;
                                _customNotification = null;
                            }
                        }
                        catch (Exception ex)
                        {
                            Trace.Main.warning("Supressing error encountered while stopping custom notification watch: {}", ex.Message);
                        }
                        try
                        {
                            if (MyInteractions != null && MyInteractions.IsWatching())
                            {
                                MyInteractions.StopWatching();
                                MyInteractions.InteractionAdded   -= MyInteractionsOnInteractionAdded;
                                MyInteractions.InteractionChanged -= MyInteractionsOnInteractionChanged;
                                MyInteractions.InteractionRemoved -= MyInteractionsOnInteractionRemoved;
                                MyInteractions = null;
                            }
                        }
                        catch (Exception ex)
                        {
                            Trace.Main.warning("Supressing error encountered while stopping my interactions watch: {}", ex.Message);
                        }

                        Context.Send(s =>
                        {
                            Interactions.Clear();
                            SelectedInteraction = null;
                        }, null);
                    }
                }
                catch (Exception ex)
                {
                    Trace.Main.exception(ex);
                }
            }
        }
Exemple #2
0
 public void ClearInteractions()
 {
     Interactions.Clear();
 }