Sha256: e6f71a366e3d983fa3ec7d5bb38ad266af1bc91277dc238e607c06fc8dbc4ffb

Contents?: true

Size: 614 Bytes

Versions: 4

Compression:

Stored size: 614 Bytes

Contents

module Dashing
  class EventsController < ApplicationController
    include ActionController::Live

    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

4 entries across 4 versions & 1 rubygems

Version Path
dashing-rails-2.4.5 app/controllers/dashing/events_controller.rb
dashing-rails-2.4.4 app/controllers/dashing/events_controller.rb
dashing-rails-2.4.3 app/controllers/dashing/events_controller.rb
dashing-rails-2.4.2 app/controllers/dashing/events_controller.rb