code: private void onStateChange(Session.State state) {
      switch (state) {
        // When the session is opened, transition the state to CONNECTED.
        case OPEN:
          setState(State.CONNECTED);
          break;
        // When the session becomes unstable, transition the state to SUSPENDED.
        case UNSTABLE:
          setState(State.SUSPENDED);
          break;
        case STALE:
          setState(State.SUSPENDED);
          this.close();
          break;
        // When the session is expired, transition the state to SUSPENDED if necessary. The recovery strategy
        // must determine whether to attempt to recover the client.
        case EXPIRED:
          setState(State.SUSPENDED);
          recoveryStrategy.recover(this);
          break;
        case CLOSED:
          setState(State.CLOSED);
          break;
        default:
          break;
      }
    }
docs: Handles a session state change.