跳至内容 跳至搜索

Action Cable Channel Callbacks

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
命名空间
包含的模块