跳至内容 跳至搜索
方法
B

实例公共方法

broadcast_to(model, message)

向此频道中此model的唯一广播广播哈希。

# File actioncable/lib/action_cable/channel/broadcasting.rb, line 16
def broadcast_to(model, message)
  ActionCable.server.broadcast(broadcasting_for(model), message)
end

broadcasting_for(model)

返回此频道中此model的唯一广播标识符

CommentsChannel.broadcasting_for("all") # => "comments:all"

你可以将任何对象作为目标传递(例如,活动记录模型),它将在底层序列化为字符串。

# File actioncable/lib/action_cable/channel/broadcasting.rb, line 26
def broadcasting_for(model)
  serialize_broadcasting([ channel_name, model ])
end