Class: ActionCable::Server::Broadcasting::Broadcaster

Inherits:
Object
  • Object
show all
Defined in:
lib/action_cable/server/broadcasting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, broadcasting) ⇒ Broadcaster

Returns a new instance of Broadcaster.


41
42
43
# File 'lib/action_cable/server/broadcasting.rb', line 41

def initialize(server, broadcasting)
  @server, @broadcasting = server, broadcasting
end

Instance Attribute Details

#broadcastingObject (readonly)

Returns the value of attribute broadcasting


39
40
41
# File 'lib/action_cable/server/broadcasting.rb', line 39

def broadcasting
  @broadcasting
end

#serverObject (readonly)

Returns the value of attribute server


39
40
41
# File 'lib/action_cable/server/broadcasting.rb', line 39

def server
  @server
end

Instance Method Details

#broadcast(message) ⇒ Object


45
46
47
48
# File 'lib/action_cable/server/broadcasting.rb', line 45

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