Sha256: 7508b07b31683abb986400ffc563fd1d010b794a3372795f243d11001d547ddd

Contents?: true

Size: 902 Bytes

Versions: 7

Compression:

Stored size: 902 Bytes

Contents

io = Sinatra::RocketIO

io.once :start do
  puts "RocketIO start!!!"
end

io.on :connect do |client|
  puts "new client  - #{client}"
  push :chat, {:name => "system", :message => "new #{client.type} client <#{client.session}>"}, :channel => client.channel
  push :chat, {:name => "system", :message => "welcome <#{client.session}>"}, :to => client.session
end

io.on :disconnect do |client|
  puts "disconnect client  - #{client}"
  push :chat, {:name => "system", :message => "bye <#{client.session}>"}, :channel => client.channel
end

io.on :chat do |data, client|
  puts "#{data['name']} : #{data['message']}  - #{client}"
  push :chat, data, :channel => client.channel
end

io.on :error do |err|
  STDERR.puts "error!! #{err}"
end

get '/' do
  redirect '/chat/1'
end

get '/chat/:channel' do
  @channel = params[:channel]
  haml :chat
end

get '/:source.css' do
  scss params[:source].to_sym
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sinatra-rocketio-0.3.3 sample/classic_style/main.rb
sinatra-rocketio-0.3.2 sample/classic_style/main.rb
sinatra-rocketio-0.3.1 sample/classic_style/main.rb
sinatra-rocketio-0.3.0 sample/classic_style/main.rb
sinatra-rocketio-0.2.6 sample/classic_style/main.rb
sinatra-rocketio-0.2.5 sample/classic_style/main.rb
sinatra-rocketio-0.2.4 sample/classic_style/main.rb