Sha256: bdb522469f3ea96163527093a7f9cdd2e2186725df0670030e3c821583db44f8

Contents?: true

Size: 1.4 KB

Versions: 61

Compression:

Stored size: 1.4 KB

Contents

# Toplevel Pubnub module.
module Pubnub
  class SubscribeEvent < Event
    # Holds methods connected with channels and cg removal
    module Removing
      def remove_groups(event)
        event.group.each do |group|
          remove_group group
          remove_g_cb group
        end
      end

      def remove_channels(event)
        event.channel.each do |channel|
          remove_channel channel
          remove_c_cb channel
        end
      end

      def remove(event = nil)
        Pubnub.logger.debug('Pubnub') { "#{self.class}#remove" }
        # kill_requester

        if event
          remove_channels(event)
          remove_groups(event)
        end

        if @channel.empty? && @group.empty?
          finish
        else
          restart_heartbeat if @heart
        end
      end

      private

      def remove_g_cb(group)
        @g_cb_pool[group] = nil
      end

      def remove_c_cb(channel)
        @c_cb_pool[channel] = nil
      end

      def remove_group(group)
        @group.delete(group)
      end

      def remove_channel(channel)
        @channel.delete(channel)
      end

      def finish(remove_itself = true)
        Pubnub.logger.debug('Pubnub') { 'Stopping subscription' }
        stop_heartbeat if @heart
        kill_requester
        @finalized = true
        return if remove_itself
        @app.env[:subscription_pool][@origin] = nil
        terminate
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
pubnub-5.4.0 lib/pubnub/subscribe_event/removing.rb
pubnub-5.3.5 lib/pubnub/subscribe_event/removing.rb
pubnub-5.3.4 lib/pubnub/subscribe_event/removing.rb
pubnub-5.3.3 lib/pubnub/subscribe_event/removing.rb
pubnub-5.3.2 lib/pubnub/subscribe_event/removing.rb
pubnub-5.3.1 lib/pubnub/subscribe_event/removing.rb
pubnub-5.3.0 lib/pubnub/subscribe_event/removing.rb
pubnub-5.2.2 lib/pubnub/subscribe_event/removing.rb
pubnub-5.2.1 lib/pubnub/subscribe_event/removing.rb
pubnub-5.2.0 lib/pubnub/subscribe_event/removing.rb
pubnub-5.1.2 lib/pubnub/subscribe_event/removing.rb
pubnub-5.1.1 lib/pubnub/subscribe_event/removing.rb
pubnub-5.1.0 lib/pubnub/subscribe_event/removing.rb
pubnub-5.0.0 lib/pubnub/subscribe_event/removing.rb
pubnub-4.8.0 lib/pubnub/subscribe_event/removing.rb
pubnub-4.7.1 lib/pubnub/subscribe_event/removing.rb
pubnub-4.7.0 lib/pubnub/subscribe_event/removing.rb
pubnub-4.6.2 lib/pubnub/subscribe_event/removing.rb
pubnub-4.6.1 lib/pubnub/subscribe_event/removing.rb
pubnub-4.6.0 lib/pubnub/subscribe_event/removing.rb