         results.push {track: track, file: file}
     return results
 
+  pushSend: (command, handler, callback) ->
+    @callbacks[command] ||= []
+    @callbacks[command].push callback
+    if $.inArray(command, @expectStack) == -1
+      @expectStack.push [command, handler]
+      @send command
+  
   handleMessage: (msg) ->
     [cmd, handler] = @expectStack.pop()
     cb handler(msg) for cb in @callbacks[cmd]

  send: (msg) ->
    @socket.emit 'ToMpd', msg + "\n"

  pushSend: (command, handler, callback) ->
    @callbacks[command] ||= []
    @callbacks[command].push callback
    if $.inArray(command, @expectStack) == -1
      @expectStack.push [command, handler]
      @send command

  getArtistList: (callback) ->
    @pushSend 'list artist', onListArtistMsg, callback

    handlersList = $.extend [], @nameToHandlers[eventName]
    handler(args...) for handler in handlersList

  onListArtistMsg = (msg) ->
    # remove the 'Artist: ' text from every line and convert to array
    list = (line.substring(8) for line in msg.split('\n'))
