code: public synchronized boolean addStateChange(ConnectionState newConnectionState)
      {
          if ( state.get() != State.STARTED )
          {
              return false;
          }
  
          ConnectionState previousState = currentConnectionState;
          if ( previousState == newConnectionState )
          {
              return false;
          }
          currentConnectionState = newConnectionState;
  
          ConnectionState localState = newConnectionState;
          boolean isNegativeMessage = ((newConnectionState == ConnectionState.LOST) || (newConnectionState == ConnectionState.SUSPENDED) || (newConnectionState == ConnectionState.READ_ONLY));
          if ( !isNegativeMessage && initialConnectMessageSent.compareAndSet(false, true) )
          {
              localState = ConnectionState.CONNECTED;
          }
  
          postState(localState);
  
          return true;
      }
docs: Post a state change. If the manager is already in that state the change
  is ignored. Otherwise the change is queued for listeners.
  
  @param newConnectionState new state
  @return true if the state actually changed, false if it was already at that state