Sha256: be211f93709b0c426b61b40d1d119c7b0b0acdb134790cd33780e3f9c7e7911e

Contents?: true

Size: 733 Bytes

Versions: 24

Compression:

Stored size: 733 Bytes

Contents

pid_file = ENV['PID_FILE'] || "/tmp/sinatra-cometio-test-pid"
File.open(pid_file, "w+") do |f|
  f.write Process.pid.to_s
end

class TestApp < Sinatra::Base
  register Sinatra::CometIO

  get '/' do
    "sinatra-cometio v#{Sinatra::CometIO::VERSION}"
  end

  Sinatra::CometIO.on :connect do |session|
    puts "new client <#{session}>"
  end

  Sinatra::CometIO.on :disconnect do |session|
    puts "disconnect client <#{session}>"
  end

  Sinatra::CometIO.on :broadcast do |data, from|
    puts from
    puts "broadcast <#{from}> - #{data.to_json}"
    push :broadcast, data
  end

  Sinatra::CometIO.on :message do |data, from|
    puts "message <#{from}> - #{data.to_json}"
    push :message, data, :to => data['to']
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
sinatra-cometio-0.5.9 test/app/main.rb
sinatra-cometio-0.5.8 test/app/main.rb
sinatra-cometio-0.5.7 test/app/main.rb
sinatra-cometio-0.5.6 test/app/main.rb
sinatra-cometio-0.5.5 test/app/main.rb
sinatra-cometio-0.5.4 test/app/main.rb
sinatra-cometio-0.5.3 test/app/main.rb
sinatra-cometio-0.5.2 test/app/main.rb
sinatra-cometio-0.5.1 test/app/main.rb
sinatra-cometio-0.5.0 test/app/main.rb
sinatra-cometio-0.4.3 test/app/main.rb
sinatra-cometio-0.4.2 test/app/main.rb
sinatra-cometio-0.4.1 test/app/main.rb
sinatra-cometio-0.4.0 test/app/main.rb
sinatra-cometio-0.3.9 test/app/main.rb
sinatra-cometio-0.3.8 test/app/main.rb
sinatra-cometio-0.3.7 test/app/main.rb
sinatra-cometio-0.3.6 test/app/main.rb
sinatra-cometio-0.3.5 test/app/main.rb
sinatra-cometio-0.3.4 test/app/main.rb