Sha256: 3f0093b705d8a88d3d98ff7949ffe0df9f3514d0e83621901171091e23914093
Contents?: true
Size: 893 Bytes
Versions: 3
Compression:
Stored size: 893 Bytes
Contents
pid_file = ENV['PID_FILE'] || "/tmp/em-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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
em-rocketio-client-0.0.3 | test/app/main.rb |
em-rocketio-client-0.0.2 | test/app/main.rb |
em-rocketio-client-0.0.1 | test/app/main.rb |