Sha256: 21fa86e9304c1adaa1c7a8ead857de1dd93b763536994ebd3a78dd162533362d

Contents?: true

Size: 661 Bytes

Versions: 4

Compression:

Stored size: 661 Bytes

Contents

module Asynchronic
  module Notifier
    class Broadcaster

      def initialize(options={})
        options[:logger] ||= Asynchronic.logger
        @broadcaster = ::Broadcaster.new options
      end

      def publish(pid, event, data=nil)
        @broadcaster.publish DataStore::Key[pid][event], data
      end

      def subscribe(pid, event, &block)
        @broadcaster.subscribe DataStore::Key[pid][event] do |data|
          block.call data
        end
      end

      def unsubscribe(subscription_id)
        @broadcaster.unsubscribe subscription_id
      end

      def unsubscribe_all
        @broadcaster.unsubscribe_all
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asynchronic-3.0.3 lib/asynchronic/notifier/broadcaster.rb
asynchronic-3.0.2 lib/asynchronic/notifier/broadcaster.rb
asynchronic-3.0.1 lib/asynchronic/notifier/broadcaster.rb
asynchronic-3.0.0 lib/asynchronic/notifier/broadcaster.rb