Sha256: 4428432b5eb50cf520d9b4089e986ba4a90596aaa33a8b32f3a4c5d81fbdbf0e

Contents?: true

Size: 397 Bytes

Versions: 4

Compression:

Stored size: 397 Bytes

Contents

require 'rubrowser/channel'

module Rubrowser
  class Connection < LiteCable::Connection::Base
    identified_by :id

    def connect
      @id = rand(100_000)
      self.class.initiate_reader
    end

    def self.initiate_reader
      @reader ||= Thread.new do
        $rd.each_line do |line|
          LiteCable.broadcast('classes', message: line.strip)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubrowser-2.10 lib/rubrowser/connection.rb
rubrowser-2.9.1 lib/rubrowser/connection.rb
rubrowser-2.9.0 lib/rubrowser/connection.rb
rubrowser-2.8.0 lib/rubrowser/connection.rb