def flush(again = false)
      if @state == :flushing
        Log.info("[offline] Starting to flush request queue of size #{@queue.size}") unless again || @mode == :initializing
        if @queue.any?
          r = @queue.shift
          options = {:token => r[:token]}
          if r[:expires_at] != 0 && (options[:time_to_live] = r[:expires_at] - Time.now.to_i) <= 0
            Log.info("[offline] Dropping queued request <#{r[:token]}> because it expired " +
                     "#{(-options[:time_to_live]).round} sec ago")
          else
            Sender.instance.send(r[:kind], r[:type], r[:payload], r[:target], options, &r[:callback])
          end
        end
        if @queue.empty?
          Log.info("[offline] Request queue flushed, resuming normal operations") unless @mode == :initializing
          @mode = :online
          @state = :running
        else
          EM.next_tick { flush(true) }
        end
      end
      true
    end
def flush(again = false)
      if @state == :flushing
        Log.info("[offline] Starting to flush request queue of size #{@queue.size}") unless again || @mode == :initializing
        if @queue.any?
          r = @queue.shift
          options = {:token => r[:token]}
          if r[:expires_at] != 0 && (options[:time_to_live] = r[:expires_at] - Time.now.to_i) <= 0
            Log.info("[offline] Dropping queued request <#{r[:token]}> because it expired " +
                     "#{(-options[:time_to_live]).round} sec ago")
          else
            Sender.instance.send(r[:kind], r[:type], r[:payload], r[:target], options, &r[:callback])
          end
        end
        if @queue.empty?
          Log.info("[offline] Request queue flushed, resuming normal operations") unless @mode == :initializing
          @mode = :online
          @state = :running
        else
          EM.next_tick { flush(true) }
        end
      end
      true
    end
Send any requests that were queued while in offline mode and have not yet timed out
 Do this asynchronously to allow for agents to respond to requests
 Once all in-memory requests have been flushed, switch off offline mode

 === Parameters
 again(Boolean):: Whether being called in a loop

 === Return
 true:: Always return true