我正在构建一个聊天应用程序,用户可以在其中私下聊天。我被困在以下几点:
一般来说,如何向有限数量的连接用户发送通知?
答案 0 :(得分:2)
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :uuid
def connect
# feel free to use any methods to store and match this
# uuid with current user
self.uuid = SecureRandom.uuid
end
end
然后在你的应用的任何部分:
ActionCable.server.broadcast user_uuid, data