def run_async(command)
      raise 'Async command already in progress' if @started
      @started = false
      @user_method.reset

      session.open_channel do |channel|
        channel.request_pty
        channel.on_data do |ch, data|
          publish_data(data, 'stdout') unless @user_method.filter_password?(data)
          @user_method.on_data(data, ch)
        end
        channel.on_extended_data { |ch, type, data| publish_data(data, 'stderr') }
        # standard exit of the command
        channel.on_request('exit-status') { |ch, data| publish_exit_status(data.read_long) }
        # on signal: sending the signal value (such as 'TERM')
        channel.on_request('exit-signal') do |ch, data|
          publish_exit_status(data.read_string)
          ch.close
          # wait for the channel to finish so that we know at the end
          # that the session is inactive
          ch.wait
        end
        channel.exec(command) do |_, success|
          @started = true
          raise('Error initializing command') unless success
        end
      end
      session.process(0) { !run_started? }
      return true
    end
def run_async(command)
      raise 'Async command already in progress' if @started
      @started = false
      @user_method.reset

      session.open_channel do |channel|
        channel.request_pty
        channel.on_data do |ch, data|
          publish_data(data, 'stdout') unless @user_method.filter_password?(data)
          @user_method.on_data(data, ch)
        end
        channel.on_extended_data { |ch, type, data| publish_data(data, 'stderr') }
        # standard exit of the command
        channel.on_request('exit-status') { |ch, data| publish_exit_status(data.read_long) }
        # on signal: sending the signal value (such as 'TERM')
        channel.on_request('exit-signal') do |ch, data|
          publish_exit_status(data.read_string)
          ch.close
          # wait for the channel to finish so that we know at the end
          # that the session is inactive
          ch.wait
        end
        channel.exec(command) do |_, success|
          @started = true
          raise('Error initializing command') unless success
        end
      end
      session.process(0) { !run_started? }
      return true
    end
Initiates run of the remote command and yields the data when
 available. The yielding doesn't happen automatically, but as
 part of calling the `refresh` method.