private void session_StateChanged(object sender, SessionListenerEventArgs e) { Log.Spew("session_StateChanged:\n\tfrom " + e.OldState + "\n\tto " + e.NewState); var justConnected = e.NewState.Connected && !e.OldState.Connected; var justDisconnected = !e.NewState.Connected && e.OldState.Connected; if (justConnected) topicManager = new TopicManager(e.Session, directInputManager, car, refreshIntervalManager, metrics); if (justDisconnected) topicManager = null; }