Sha256: 06708f76f006dc8c76bd2f1d71d8fb5dcd9d6dd63a81d9419d90e39ee370f1c0

Contents?: true

Size: 602 Bytes

Versions: 3

Compression:

Stored size: 602 Bytes

Contents

class PushRoutesListener

  def initialize
    @updates = {}
    @redis_connected = false
    Thread.new {
      redis_subscirber = Redis.new(:url => PushRoutes.REDIS_URL);
      @redis_connected = true
      redis_subscirber.subscribe('rt-change') do |on|
        on.message do |channel, message|
          c = JSON.parse(message)["channel"]
          @updates[c] = @updates[c].to_i + 1
        end
      end
    }

    #Wait for redis subscriber to start
    while (!@redis_connected)
    end
    sleep 0.5
  end

  def reset
    @updates = {}
  end

  def number_of(s)
    @updates[s] || 0
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
push_routes-0.0.8 test/push_routes_listener.rb
push_routes-0.0.7 test/push_routes_listener.rb
push_routes-0.0.6 test/push_routes_listener.rb