gpt4 book ai didi

ruby-on-rails - Action 线 : Notify a single user

转载 作者:数据小太阳 更新时间:2023-10-29 08:02:52 26 4
gpt4 key购买 nike

我正在构建一个用户可以私下聊天的聊天应用程序。我被困在以下几点:

  • “用户 A”点击“用户 B”的聊天图标,现在我们需要向单个“用户 B”发送通知。如何实现这一目标?
  • “用户 A”有 N 个 friend 。当'用户A'掉线时,如何只通知系统中的N个好友?

那么一般来说,如何向有限数量的连接用户发送通知?

最佳答案

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

关于ruby-on-rails - Action 线 : Notify a single user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39393298/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com