Sha256: 653161677fb1e823a47dfaf5ba0011bdc1001ec5f922f3c1a776d0eb6aab97f7

Contents?: true

Size: 347 Bytes

Versions: 11

Compression:

Stored size: 347 Bytes

Contents

require 'json'

module Bait
  class << self
    @@Subscribers = []
    def add_subscriber stream
      @@Subscribers << stream
    end
    def remove_subscriber stream
      @@Subscribers.delete stream        
    end
    def broadcast *args
      @@Subscribers.each do |out|
        out << "data: #{args.to_json}\n\n"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bait-0.5.13 lib/bait/pubsub.rb
bait-0.5.12 lib/bait/pubsub.rb
bait-0.5.11 lib/bait/pubsub.rb
bait-0.5.10 lib/bait/pubsub.rb
bait-0.5.9 lib/bait/pubsub.rb
bait-0.5.6 lib/bait/pubsub.rb
bait-0.5.5 lib/bait/pubsub.rb
bait-0.5.4 lib/bait/pubsub.rb
bait-0.5.2 lib/bait/pubsub.rb
bait-0.5.1 lib/bait/pubsub.rb
bait-0.5.0 lib/bait/pubsub.rb