Homeland 请教大神 homeland 哪里一部分 用到 websocket 网站提示 www.xxxx.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

sdfsd · 2020年08月19日 · 最后由 sdfsd 回复于 2020年08月21日 · 1160 次阅读

请教大神 homeland 哪里一部分 用到 websoct 网站提示 www.xxxx.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

简单喵了一下,起码创建回复的时候会有。

# frozen_string_literal: true

class NotifyReplyJob < ApplicationJob
  queue_as :notifications

  def perform(reply_id)
    reply = Reply.find_by_id(reply_id)
    return if reply.blank?
    return if reply.system_event?

    Notification.bulk_insert(set_size: 100) do |worker|
      reply.notification_receiver_ids.each do |uid|
        logger.debug "Post Notification to: #{uid}"
        note = reply.send(:default_notification).merge(user_id: uid)
        worker.add(note)
      end
    end

    # Touch realtime_push_to_client
    reply.notification_receiver_ids.each do |uid|
      n = Notification.where(user_id: uid).last
      n.realtime_push_to_client if n.present?
    end
    reply.broadcast_to_client  # 推送给用户
  end
end

broadcast_to_client就是服务端推送。

lanzhiheng 回复

谢谢大神

需要 登录 后方可回复, 如果你还没有账号请 注册新账号