Sha256: 58651cc2deff6bd02102712417857f430dbecc3f1bda97758200eb09dae99632

Contents?: true

Size: 636 Bytes

Versions: 13

Compression:

Stored size: 636 Bytes

Contents

module Dashing
  class EventsController < ApplicationController
    include ActionController::Live

    respond_to :html

    def index
      response.headers['Content-Type']      = 'text/event-stream'
      response.headers['X-Accel-Buffering'] = 'no'

      @redis = Dashing.redis
      @redis.psubscribe("#{Dashing.config.redis_namespace}.*") do |on|
        on.pmessage do |pattern, event, data|
          response.stream.write("data: #{data}\n\n")
        end
      end
    rescue IOError
      logger.info "[Dashing][#{Time.now.utc.to_s}] Stream closed"
    ensure
      @redis.quit
      response.stream.close
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dashing-rails-2.4.1 app/controllers/dashing/events_controller.rb
dashing-rails-2.4.0 app/controllers/dashing/events_controller.rb
dashing-rails-2.3.2 app/controllers/dashing/events_controller.rb
dashing-rails-2.3.1 app/controllers/dashing/events_controller.rb
dashing-rails-2.3.0 app/controllers/dashing/events_controller.rb
dashing-rails-2.2.0 app/controllers/dashing/events_controller.rb
dashing-rails-2.1.1 app/controllers/dashing/events_controller.rb
dashing-rails-2.1.0 app/controllers/dashing/events_controller.rb
dashing-rails-2.0.2 app/controllers/dashing/events_controller.rb
dashing-rails-2.0.1 app/controllers/dashing/events_controller.rb
dashing-rails-2.0.0 app/controllers/dashing/events_controller.rb
dashing-rails-1.0.3 app/controllers/dashing/events_controller.rb
dashing-rails-1.0.2 app/controllers/dashing/events_controller.rb