lib/envoy/server/trunk.rb in envoy-proxy-0.1.3 vs lib/envoy/server/trunk.rb in envoy-proxy-0.1.4

- old
+ new

@@ -30,10 +30,14 @@ def channels @channels ||= {} end def receive_pong + EM.add_timer 5 do + log "ping" + send_object :ping + end end def receive_close id, code = nil if chan = channels[id] chan.web.close(code) @@ -60,19 +64,20 @@ send_object :message, message if message send_object :halt close_connection(true) end + def version? *requirement + Gem::Requirement.new(*requirement) =~ Gem::Version.new(@options[:version]) + end + def receive_options options @options = options - if (@options[:version].split(".").map(&:to_i) <=> [0, 1, 0]) > -1 - EM.add_periodic_timer 5 do - send_object :ping - end - else - EM.add_periodic_timer 20 do - send_object :message, "Checking client is still here. Upgrade to hide this message." - end + if version? "~> 0.1" + receive_pong + end + if version? "< #{Envoy::VERSION}" + send_object :message, "Your client is out of date. Please upgrade to #{Envoy::VERSION}." end if @key and @key != @options[:key] halt "Key is invalid" return end