跳至内容 跳至搜索

Action Cable 频道回调

Action Cable Channel 提供了在频道生命周期中调用的回调挂钩

示例

class ChatChannel < ApplicationCable::Channel
  after_subscribe :send_welcome_message, unless: :subscription_rejected?
  after_subscribe :track_subscription

  private
    def send_welcome_message
      broadcast_to(...)
    end

    def track_subscription
      # ...
    end
end
命名空间
包含的模块