方法
執行個體公開方法
broadcast_to(model, message) 連結
在這個頻道中,將雜湊廣播到這個 model
的唯一廣播。
來源: 顯示 | 在 GitHub 上
# File actioncable/lib/action_cable/channel/broadcasting.rb, line 14 def broadcast_to(model, message) ActionCable.server.broadcast(broadcasting_for(model), message) end
broadcasting_for(model) 連結
傳回在這個頻道中,這個 model
的唯一廣播識別碼
CommentsChannel.broadcasting_for("all") # => "comments:all"
你可以傳入任何物件作為目標(例如 Active Record 型別),然後它會在底層序列成字串。
來源: 顯示 | 在 GitHub 上
# File actioncable/lib/action_cable/channel/broadcasting.rb, line 24 def broadcasting_for(model) serialize_broadcasting([ channel_name, model ]) end