/**
   * Logs the current user out and clear the username and auth token. This will terminate the
   * broadcast if necessary.
   */
  public boolean logout() {
    if (getIsIngestTesting()) {
      return false;
    }

    // stop synchronously
    if (this.getIsBroadcasting()) {
      m_Stream.stop(false);
    }

    m_UserName = "";
    m_AuthToken = new AuthToken();

    if (!m_LoggedIn) {
      return false;
    }

    m_LoggedIn = false;

    // only fire the event if the logout was explicitly requested
    if (!m_ShuttingDown) {
      try {
        if (m_Listener != null) {
          m_Listener.onLoggedOut();
        }
      } catch (Exception x) {
        reportError(x.toString());
      }
    }

    setBroadcastState(BroadcastState.Initialized);

    return true;
  }