Module: Rmpd::Command::CommandListStrategy

Defined in:
lib/rmpd/command.rb

Instance Method Summary collapse

Instance Method Details

#execute(connection, *args) {|list| ... } ⇒ Object

Yields:

  • (list)


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/rmpd/command.rb', line 93

def execute(connection, *args, &block)
  tries = 0
  list = List.new
  yield list

  begin
    connection.synchronize do
      connection.send_command("command_list_begin")
      list.map do |command_w_args|
        connection.send_command(*command_w_args)
      end
      connection.send_command("command_list_end")
      Response.factory(@name).parse(connection.read_response)
    end
  rescue MpdDisconnectedError => e
    tries += 1
    if tries < 5
      puts "CommandListStrategy MpdDisconnectedError received, retrying" if $DEBUG
      connect
      retry
    else
      puts "CommandListStrategy retries exceeded" if $DEBUG
      raise e
    end
  end
end