Tenno Seremel [2010-02-03 01:02]:
> >You have to return true from the callback if you want it to be called
> >again.
> 
> This is it! That why I had weird behavoir sometimes before (ruby returns
> the last executed command's result). I didn't thought of it...

Would you like to explain this behaviour in the tutorials and submit a
patch?

Re event loops:
I'm attaching one of my Ruby test clients that shows how to use the
event-loop package in an XMMS2 client.

Regards,
Tilman

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
require 'xmmsclient'
require 'event-loop'

module Xmms
        class Client
                def add_to_event_loop
                        @io = IO.for_fd(io_fd)

                        @io.on_readable { io_in_handle }
                        @io.on_writable { io_out_handle }

                        EventLoop.on_before_sleep do
                                if io_want_out
                                        @io.monitor_event(:writable)
                                else
                                        @io.ignore_event(:writable)
                                end
                        end
                end
        end
end

$num_songs = 2310
$left = $num_songs
$received = 0
$results = []

def tada(value)
        unless value.nil?
                #propdict = value.to_propdict

                #p propdict[:id]
        end

        $left -= 1
        $received += 1

        puts "got #{$received} so far"

        EventLoop.quit if $left.zero?

        1 # keep going
end

client = Xmms::Client.new("crap")
client.connect(ENV["XMMS_PATH"])
client.add_to_event_loop
client.on_disconnect { EventLoop.quit }

1.upto($num_songs) do |i|
        result = client.medialib_get_info(i)
        result.notifier(&method(:tada))

        $results << result
end

=begin
offset = 0

($num_songs / 2).times do |i|
        j = i - offset
        puts "deleting #{j}"
        $results.delete_at(j).cancel

        offset += 1
end
=end

EventLoop.run
--
_______________________________________________
Xmms2-devel mailing list
Xmms2-devel@lists.xmms.se
http://lists.xmms.se/cgi-bin/mailman/listinfo/xmms2-devel

Reply via email to