Sha256: 5b01f3cfc279ac1f6168f49fc4d8e36715b0c2287846df2349da9ec55104500c

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 Bytes

Contents

class Cubism::PresenceChannel < ActionCable::Channel::Base
  include CableReady::StreamIdentifier

  def subscribed
    if resource.present?
      stream_for resource
      resource.present_users.add(user.id)
    else
      reject
    end
  end

  def unsubscribed
    return unless resource.present?

    resource.present_users.remove(user.id)
  end

  private

  def resource
    locator = verified_stream_identifier(params[:identifier])
    GlobalID::Locator.locate(locator)
  end

  def user
    GlobalID::Locator.locate_signed(params[:user])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cubism-0.1.0.pre5 app/channels/cubism/presence_channel.rb~
cubism-0.1.0.pre4 app/channels/cubism/presence_channel.rb~
cubism-0.1.0.pre3 app/channels/cubism/presence_channel.rb