Sha256: b5d764f51e0a0098cffc64517f597b68fb5af7fefe2665b8d68e60242082d4af
Contents?: true
Size: 829 Bytes
Versions: 7
Compression:
Stored size: 829 Bytes
Contents
class ChatApp < Sinatra::Base register Sinatra::RocketIO io = Sinatra::RocketIO io.on :connect do |session, type| puts "new client <#{session}> (type:#{type})" push :chat, {:name => "system", :message => "new #{type} client <#{session}>"} push :chat, {:name => "system", :message => "welcome <#{session}>"}, {:to => session} end io.on :disconnect do |session, type| puts "disconnect client <#{session}> (type:#{type})" push :chat, {:name => "system", :message => "bye <#{session}>"} end io.on :chat do |data, from, type| puts "#{data['name']} : #{data['message']} (from:#{from} type:#{type})" push :chat, data end io.on :error do |err| STDERR.puts "error!! #{err}" end get '/' do haml :index end get '/:source.css' do scss params[:source].to_sym end end
Version data entries
7 entries across 7 versions & 1 rubygems