Sha256: 20debb45614d72084e56029f412d08dee51f74a1c501bb7fc41fcbd54fd76768

Contents?: true

Size: 898 Bytes

Versions: 9

Compression:

Stored size: 898 Bytes

Contents

pid_file = ENV['PID_FILE'] || "/tmp/sinatra-rocketio-test-pid"
EM::defer do
  while !EM::reactor_running? do
    sleep 0.1
  end
  File.open(pid_file, "w+") do |f|
    f.write Process.pid.to_s
  end
end

class TestApp < Sinatra::Base
  register Sinatra::RocketIO
  io = Sinatra::RocketIO

  get '/' do
    "sinatra-rocketio v#{Sinatra::RocketIO::VERSION}"
  end

  io.on :connect do |session, type|
    puts "new client <session:#{session}> <type:#{type}>"
  end

  io.on :disconnect do |session, type|
    puts "disconnect client <session:#{session}> <type:#{type}>"
  end

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

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

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sinatra-rocketio-0.1.2 test/app/main.rb
sinatra-rocketio-0.1.1 test/app/main.rb
sinatra-rocketio-0.1.0 test/app/main.rb
sinatra-rocketio-0.0.9 test/app/main.rb
sinatra-rocketio-0.0.8 test/app/main.rb
sinatra-rocketio-0.0.7 test/app/main.rb
sinatra-rocketio-0.0.6 test/app/main.rb
sinatra-rocketio-0.0.5 test/app/main.rb
sinatra-rocketio-0.0.4 test/app/main.rb