0

I want to implement something like whatsapp message, when you are not connected and you are connected again your message is arrived. but for that I implement after_subscribe the callback method forwading_queues than is executed after subscription channel. The problem is when there was some disconnection from client, and quickly he is connected again the method forwading_queues is executed but no send broadcast, I think that is because the old connection is active yet and the broadcast is send to old connection, because sometimes after the server said THE USER WAS DISCONNECTED but the broadcast_to was already executed in the method forwading_queues

class UserChannel < ApplicationCable::Channel
 after_subscribe :forwading_queues
 def subscribed
  stream_for current_user
 end

 def forwading_queues
  UserChannel.broadcast_to current_user, {message: 'You are back!'}
 end
end

Do you know what is happening here ?

H4xorPL
  • 320
  • 3
  • 11
Darlyn
  • 310
  • 1
  • 2
  • 16

0 Answers0