Class: Loco::NotificationCenterChannel

Inherits:
ApplicationCable::Channel show all
Defined in:
app/channels/loco/notification_center_channel.rb

Instance Method Summary collapse

Instance Method Details

#receive(data) ⇒ Object



19
20
21
22
# File 'app/channels/loco/notification_center_channel.rb', line 19

def receive data
  update_connections if data['loco'] && data['loco']['connection_check']
  NotificationCenter.new.received_signal permissions, data
end

#subscribedObject



5
6
7
8
9
10
# File 'app/channels/loco/notification_center_channel.rb', line 5

def subscribed
  return unless loco_permissions.is_a?(Array)
  stream_for_resources
  return if loco_permissions.compact.size > 1
  SenderJob.perform_later @uuid, loco: { start_ajax_polling: true }
end

#unsubscribedObject



12
13
14
15
16
17
# File 'app/channels/loco/notification_center_channel.rb', line 12

def unsubscribed
  loco_permissions.each do |resource|
    next if resource.nil? || resource.is_a?(String)
    UuidJob.perform_later serialize_resource(resource), @uuid, 'del'
  end
end