logo
  • 教程列表
  • SO官方文檔
  • ActionCable
    • 使用者認證
    • 基本伺服器端
    • 基本客戶端(Coffeescript)
  1. StackOverflow 文件
  2. Ruby on Rails 教程
  3. ActionCable
  4. 基本伺服器端

基本伺服器端

Created: November-22, 2018

# app/channels/appearance_channel.rb
class NotificationsChannel < ApplicationCable::Channel
  def subscribed
    stream_from "notifications"
  end

  def unsubscribed
  end

  def notify(data)
    ActionCable.server.broadcast "notifications", { title: 'New things!', body: data }
  end
end
  • 基本客戶端(Coffeescript)
  • 使用者認證

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明