Module: Rmpd::Command::CommandStrategy

Defined in:
lib/rmpd/command.rb

Instance Method Summary collapse

Instance Method Details

#execute(connection, *args) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rmpd/command.rb', line 70

def execute(connection, *args)
  tries = 0
  begin
    connection.synchronize do
      connection.send_command(@name, *args)
      Response.factory(@name).parse(connection.read_response)
    end
  rescue MpdDisconnectedError => e
    tries += 1
    if tries < 5
      puts "CommandStrategy MpdDisconnectedError received, retrying" if $DEBUG
      connection.connect
      retry
    else
      puts "CommandStrategy retries exceeded" if $DEBUG
      raise e
    end
  end
end