Sha256: f708974e287aa69df223453c9c1bd151733ffbb4dff90b117fe51d58457a0da1

Contents?: true

Size: 654 Bytes

Versions: 4

Compression:

Stored size: 654 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

CometIO.on :disconnect do |session|
  puts "disconnect client <#{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

4 entries across 4 versions & 1 rubygems

Version Path
sinatra-cometio-0.1.5 sample/main.rb
sinatra-cometio-0.1.4 sample/main.rb
sinatra-cometio-0.1.3 sample/main.rb
sinatra-cometio-0.1.2 sample/main.rb