aboutsummaryrefslogblamecommitdiffstats
path: root/lib/action_cable/broadcaster.rb
blob: b2352876e9fa586819cd071372d09468616dfe8d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                                                  
module ActionCable
  class Broadcaster
    attr_reader :server, :channel, :redis
    delegate :logger, to: :server

    def initialize(server, channel)
      @server = server
      @channel = channel
      @redis = @server.threaded_redis
    end

    def broadcast(message)
      redis.publish channel, message.to_json
      logger.info "[ActionCable] Broadcasting to channel (#{channel}): #{message}"
    end

  end
end