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

sdfsd · August 19, 2020 · Last by sdfsd replied at August 21, 2020 · 1382 hits

请教大神 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就是服务端推送。

Reply to lanzhiheng

谢谢大神

You need to Sign in before reply, if you don't have an account, please Sign up first.