lib/sinatra/cometio.rb in sinatra-cometio-0.1.1 vs lib/sinatra/cometio.rb in sinatra-cometio-0.1.2
- old
+ new
@@ -19,10 +19,11 @@
def self.gc
self.sessions.each do |id, s|
next unless s[:last] and s[:last] < Time.now-60
self.sessions.delete id rescue next
+ self.emit :disconnect, id
end
end
EM::defer do
loop do
@@ -50,10 +51,10 @@
end
end
end
end
- def self.create_session
- Digest::MD5.hexdigest "#{Time.now.to_i}_#{Time.now.usec}"
+ def self.create_session(ip_addr)
+ Digest::MD5.hexdigest "#{Time.now.to_i}_#{Time.now.usec}_#{ip_addr}"
end
end
EventEmitter.apply CometIO