Skip to Content Skip to Search

class ActionCable::Server::Broadcasting::Broadcaster

Attributes

[R] broadcasting
[R] coder
[R] server

Public class methods

Source code GitHub
# File actioncable/lib/action_cable/server/broadcasting.rb, line 46
def initialize(server, broadcasting, coder:)
  @server, @broadcasting, @coder = server, broadcasting, coder
end

Public instance methods

Source code GitHub
# File actioncable/lib/action_cable/server/broadcasting.rb, line 50
def broadcast(message)
  server.logger.debug { "[ActionCable] Broadcasting to #{broadcasting}: #{message.inspect.truncate(300)}" }

  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

Definition files