lib/xmpp4r/robot.rb in xmpp4r-robot-0.2.2 vs lib/xmpp4r/robot.rb in xmpp4r-robot-0.2.3

- old
+ new

@@ -20,10 +20,11 @@ @retry_time = Float(opts[:retry_time] || 0) @auto_accept_subscription = opts[:auto_accept_subscription] @roster_mutex = Mutex.new @helper_mutex = Mutex.new + @client = nil # eliminate warning end def inspect "#<#{self.class.name} username=#{username.inspect}>" end @@ -128,15 +129,18 @@ ##### private ##### private def initialize_callbacks client.on_exception do |exp| + next unless exp # why exp might be nil? errback.call(exp) if errback next if retry_time == 0.0 $stderr.puts "ERROR: #{exp}: #{exp.backtrace}" + " We'll sleep for #{retry_time} seconds and retry." + + clear_roster_semaphore sleep(retry_time) start end client.add_presence_callback do |presence|