Sha256: 31720d470fe9f5a22a6a0a0c7c4e60fb9b68999c1a9a30ff4f26e4fb4c708ead
Contents?: true
Size: 1.27 KB
Versions: 6
Compression:
Stored size: 1.27 KB
Contents
class Cubism::PresenceChannel < ActionCable::Channel::Base include CableReady::StreamIdentifier 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 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 def appear resource.set_present_users_for_scope(resource.present_users_for_scope(scope).add(user.id), scope) if scope end def disappear resource.set_present_users_for_scope(resource.present_users_for_scope(scope).delete(user.id), scope) if scope end private def resource locator = verified_stream_identifier(params[:identifier]) GlobalID::Locator.locate(locator) end def user block_container&.user end def scope block_container&.scope end def block_container Cubism.block_store[element_id] end def exclude_current_user? params[:exclude_current_user] end def element_id /cubicle-(?<element_id>.+)/ =~ params[:element_id] element_id end def url params[:url] end end
Version data entries
6 entries across 6 versions & 1 rubygems