Sha256: e48c26f8d535c77d729bef53d36c6d33b963338f03e4ebcfa828dd0aba94e2d6

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

# :markup: markdown

module ActionCable
  module SubscriptionAdapter
    class Inline < Base # :nodoc:
      def initialize(*)
        super
        @mutex = Mutex.new
        @subscriber_map = nil
      end

      def broadcast(channel, payload)
        subscriber_map.broadcast(channel, payload)
      end

      def subscribe(channel, callback, success_callback = nil)
        subscriber_map.add_subscriber(channel, callback, success_callback)
      end

      def unsubscribe(channel, callback)
        subscriber_map.remove_subscriber(channel, callback)
      end

      def shutdown
        # nothing to do
      end

      private
        def subscriber_map
          @subscriber_map || @mutex.synchronize { @subscriber_map ||= new_subscriber_map }
        end

        def new_subscriber_map
          SubscriberMap.new
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
actioncable-next-0.1.2 lib/action_cable/subscription_adapter/inline.rb
actioncable-next-0.1.1 lib/action_cable/subscription_adapter/inline.rb
actioncable-next-0.1.0 lib/action_cable/subscription_adapter/inline.rb