lib/envoy/server/trunk.rb in envoy-proxy-0.0.19 vs lib/envoy/server/trunk.rb in envoy-proxy-0.1.0
- old
+ new
@@ -12,18 +12,25 @@
def self.trunks
@trunks ||= Hash.new{|h,k|h[k] = []}
end
+ def post_init
+ self.comm_inactivity_timeout = 25
+ end
+
def hosts
@hosts ||= []
end
def channels
@channels ||= {}
end
+ def receive_pong
+ end
+
def receive_close id, code = nil
if chan = channels[id]
chan.web.close(code)
channels.delete id
end
@@ -50,10 +57,19 @@
close_connection(true)
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
+ end
if @key and @key != @options[:key]
halt "Key is invalid"
return
end
hosts = @options[:hosts] || []
@@ -79,10 +95,10 @@
end
send_object :message, m.join(" ")
unless @options[:key]
@options[:key] ||= SecureRandom.hex(8)
send_object :message, "Your key is #{@options[:key]}"
- end
+ end
end
def unbind
hosts.each do |host|
Trunk.trunks[host].delete self