Class: Cubism::PresenceChannel
- Inherits:
-
ActionCable::Channel::Base
- Object
- ActionCable::Channel::Base
- Cubism::PresenceChannel
- Includes:
- CableReady::StreamIdentifier
- Defined in:
- app/channels/cubism/presence_channel.rb
Instance Method Summary collapse
Instance Method Details
#appear ⇒ Object
22 23 24 25 26 |
# File 'app/channels/cubism/presence_channel.rb', line 22 def appear resource.set_present_users_for_scope(resource.present_users_for_scope(scope).add(user.id), scope) if scope rescue ActiveRecord::RecordNotFound # do nothing if the user wasn't found end |
#disappear ⇒ Object
28 29 30 31 32 |
# File 'app/channels/cubism/presence_channel.rb', line 28 def disappear resource.set_present_users_for_scope(resource.present_users_for_scope(scope).delete(user.id), scope) if scope rescue ActiveRecord::RecordNotFound # do nothing if the user wasn't found end |
#subscribed ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/channels/cubism/presence_channel.rb', line 4 def subscribed if resource.present? stream_from element_id resource.cubicle_element_ids << element_id resource.excluded_user_id_for_element_id[element_id] = user.id if exclude_current_user? else reject end end |
#unsubscribed ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/channels/cubism/presence_channel.rb', line 14 def unsubscribed return unless resource.present? resource.cubicle_element_ids.remove(element_id) resource.excluded_user_id_for_element_id.delete(element_id) disappear end |