Ruby on rails Rails 5 ActionCable修改确认订阅
我有这个频道:Ruby on rails Rails 5 ActionCable修改确认订阅,ruby-on-rails,ruby-on-rails-5,actioncable,Ruby On Rails,Ruby On Rails 5,Actioncable,我有这个频道: class TestChannel < ApplicationCable::Channel def subscribed stream_from 'test' ActionCable.server.broadcast 'Test', vehicles: Vehice.find_by id: 13 end end class TestChannel
class TestChannel < ApplicationCable::Channel
def subscribed
stream_from 'test'
ActionCable.server.broadcast 'Test', vehicles: Vehice.find_by id: 13
end
end
class TestChannel
当有人订阅时,我不想向所有订户广播。
我正在考虑通过添加“消息”
来更改确认订阅
有人能告诉我这是否可能吗?您可以使用只向当前订阅发送消息。它并没有真正的文档化,而且某种程度上是一种反模式(因为在发布子场景中,频道中的每条消息都应该到达每个用户),但它工作得很好。当客户端发送无效请求时,我们使用它来“响应”错误消息