Sha256: e72bd8d20235ce73dd77328b8bad9e92407304a32dad353faec918c825be66bc

Contents?: true

Size: 573 Bytes

Versions: 10

Compression:

Stored size: 573 Bytes

Contents

CometIO.on :chat do |data, from|
  puts "#{data['name']} : #{data['message']}  (from:#{from})"
  self.push :chat, data
end

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

EM::defer do
  loop do
    CometIO.push :chat, :name => 'clock', :message => Time.now.to_s
    sleep 60
  end
end

get '/' do
  haml :index
end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sinatra-cometio-0.1.1 sample/main.rb
sinatra-cometio-0.1.0 sample/main.rb
sinatra-cometio-0.0.9 sample/main.rb
sinatra-cometio-0.0.8 sample/main.rb
sinatra-cometio-0.0.7 sample/main.rb
sinatra-cometio-0.0.6 sample/main.rb
sinatra-cometio-0.0.5 sample/main.rb
sinatra-cometio-0.0.4 sample/main.rb
sinatra-cometio-0.0.3 sample/main.rb
sinatra-cometio-0.0.2 sample/main.rb