code: boolean connectionStateChanged(int newState) {
      switch (newState) {
        case ConnectionManager.CONNECTED:
          LOG.info(listeningPort + ": Switched to CONNECTED state.");
          // Try to resubscribe all the watched events
          try {
            return resubscribe();
          } catch (Exception e) {
            LOG.error(listeningPort + ": Resubscribing failed", e);
            return false;
          }
        case ConnectionManager.DISCONNECTED_VISIBLE:
          LOG.info(listeningPort + ": Switched to DISCONNECTED_VISIBLE state");
          for (NamespaceEventKey eventKey : watchedEvents.keySet())
            watchedEvents.put(eventKey, -1L);
          watcher.connectionFailed();
          break;
        case ConnectionManager.DISCONNECTED_HIDDEN:
          LOG.info(listeningPort + ": Switched to DISCONNECTED_HIDDEN state.");
      }
  
      return true;
    }
docs: Called by the ConnectionManager when the connection state changed.
  The connection lock is hold when calling this method, so no
  other methods from the ConnectionManager should be called here.
  
  @param newState the new state
  @return when the new state is DISCONNECTED_HIDDEN or DISCONNECTED_VISIBLE,
  then the return value is ignored. If the new state is CONNECTED,
  then the return value shows if the NamespaceNotifierClient accepts
  or not the new server. If it isn't accepted, the ConnectionManager
  will try connecting to another server.