about summary refs log tree commit homepage
path: root/lib/dtas/player/client_handler.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-09-09 09:06:44 +0000
committerEric Wong <normalperson@yhbt.net>2013-09-09 09:06:44 +0000
commit9948975066981b6d9dfbbb18adc7013341a26634 (patch)
tree3cf6c2ba231bd381659489c6aef30115313154d9 /lib/dtas/player/client_handler.rb
parent385563d1d99fda2735c78884ab135c8b77bc651a (diff)
downloaddtas-9948975066981b6d9dfbbb18adc7013341a26634.tar.gz
This is necessary to handle the case where the tracklist is empty,
clients get confused and timeout the response if we attempt to emit
an empty string.
Diffstat (limited to 'lib/dtas/player/client_handler.rb')
-rw-r--r--lib/dtas/player/client_handler.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb
index 6070851..70d992b 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -567,9 +567,10 @@ module DTAS::Player::ClientHandler # :nodoc:
     when "get"
       res = @tl.get_tracks(msg.map! { |i| i.to_i })
       res.map! { |tid, file| "#{tid}=#{file ? Shellwords.escape(file) : ''}" }
-      io.emit(res.join(' '))
+      io.emit("#{res.size} #{res.join(' ')}")
     when "tracks"
-      io.emit(@tl.tracks.map! { |i| i.to_s }.join(' '))
+      tracks = @tl.tracks
+      io.emit("#{tracks.size} " << tracks.map! { |i| i.to_s }.join(' '))
     when "goto"
       track_id = msg.shift or return io.emit("ERR track_id not specified")
       offset = msg.shift # may be nil