跳至内容 跳至搜索
方法
B
N

属性

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

类公共方法

new(server, broadcasting, coder:)

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

实例公共方法

broadcast(message)

# 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