123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Inherits: Object
Defined in: actioncable/lib/action_cable/server/broadcasting.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(server, broadcasting, coder:) ⇒ Broadcaster

[ GitHub ]

  
# File 'actioncable/lib/action_cable/server/broadcasting.rb', line 38

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

Instance Attribute Details

#broadcasting (readonly)

[ GitHub ]

  
# File 'actioncable/lib/action_cable/server/broadcasting.rb', line 36

attr_reader :server, :broadcasting, :coder

#coder (readonly)

[ GitHub ]

  
# File 'actioncable/lib/action_cable/server/broadcasting.rb', line 36

attr_reader :server, :broadcasting, :coder

#server (readonly)

[ GitHub ]

  
# File 'actioncable/lib/action_cable/server/broadcasting.rb', line 36

attr_reader :server, :broadcasting, :coder

Instance Method Details

#broadcast(message)

[ GitHub ]

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

def broadcast(message)
  server.logger.debug "[ActionCable] Broadcasting to #{broadcasting}: #{message.inspect}"

  payload = { broadcasting: broadcasting, message: message, coder: coder }
  ActiveSupport::Notifications.instrument("broadcast.action_cable", payload) do
    encoded = coder ? coder.encode(message) : message
    server.pubsub.broadcast broadcasting, encoded
  end
end