Class: Loco::NotificationCenterChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ApplicationCable::Channel
- Loco::NotificationCenterChannel
- Defined in:
- app/channels/loco/notification_center_channel.rb
Instance Method Summary collapse
Instance Method Details
#receive(payload) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/channels/loco/notification_center_channel.rb', line 22 def receive(payload) if payload.dig('loco', 'pong') update_connections broadcast_to(@uuid, loco: { ping: true }) end return if payload.keys == ['loco'] = PermissionsPresenter.indexed() NotificationCenter.new.(, payload) end |
#subscribed ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/channels/loco/notification_center_channel.rb', line 5 def subscribed return unless .is_a?(Array) @uuid, *signed_in_resources = PermissionsPresenter.signed_in() return unless @uuid.is_a?(String) stream_from("loco:notification_center:#{@uuid}") broadcast_to(@uuid, loco: { uuid: @uuid }) signed_in_resources.each { |resource| WsConnectionManager.new(resource).add(@uuid) } end |
#unsubscribed ⇒ Object
16 17 18 19 20 |
# File 'app/channels/loco/notification_center_channel.rb', line 16 def unsubscribed PermissionsPresenter.signed_in(, except: :uuid).each do |resource| WsConnectionManager.new(resource).del(@uuid) end end |