sample/main.rb in sinatra-cometio-0.1.1 vs sample/main.rb in sinatra-cometio-0.1.2
- old
+ new
@@ -7,9 +7,13 @@
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