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

  • 关于我们
  • 免责声明