Module: Fargo::Supports::FileList
Defined Under Namespace
Classes: Listing
Instance Method Summary collapse
-
#file_list(nick) ⇒ Object
Lazily load the file list for the nick.
-
#file_list!(nick, timeout = 10) ⇒ Object
Wait for the results to arrive, timed out after some time.
Instance Method Details
#file_list(nick) ⇒ Object
Lazily load the file list for the nick. Subscribe to the client for the event :file_list to get notified.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fargo/supports/file_list.rb', line 17 def file_list nick if @file_list.has_key?(nick) return parse_file_list(@file_list[nick], nick) elsif @getting_file_list[nick] return true end subscription_id = channel.subscribe do |type, map| case type when :download_finished, :download_failed, :connection_timeout if map[:nick] == nick @file_list[nick] = map[:file] channel.unsubscribe subscription_id channel << [:file_list, {:nick => nick, :list => @file_list[nick]}] @getting_file_list.delete nick end end end @getting_file_list[nick] = true download nick, 'files.xml.bz2' end |
#file_list!(nick, timeout = 10) ⇒ Object
Wait for the results to arrive, timed out after some time
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fargo/supports/file_list.rb', line 44 def file_list! nick, timeout = 10 if @file_list.has_key?(nick) return parse_file_list(@file_list[nick], nick) end list = nil list_gotten = lambda{ |type, map| if type == :file_list && map[:nick] == nick list = map[:list] true else false end } timeout_response(timeout, list_gotten){ file_list nick } parse_file_list list, nick end |