lib/proxymachine.rb in fizx-proxymachine-1.6.1 vs lib/proxymachine.rb in fizx-proxymachine-1.7.0

- old
+ new

@@ -4,10 +4,11 @@ require 'logger' require 'socket' require 'proxymachine/client_connection' require 'proxymachine/server_connection' +require 'proxymachine/warning_server_connection' require 'proxymachine/callback_server_connection' $logger = Logger.new(STDOUT) class ProxyMachine @@ -83,23 +84,32 @@ end def self.set_inactivity_error_callback(&block) @@inactivity_error_callback = block end + + def self.set_inactivity_warning_callback(&block) + @@inactivity_warning_callback = block + end def self.inactivity_error_callback @@inactivity_error_callback end + + def self.inactivity_warning_callback + @@inactivity_warning_callback + end def self.run(name, host, port) @@totalcounter = 0 @@maxcounter = 0 @@counter = 0 @@name = name @@listen = "#{host}:#{port}" @@connect_error_callback ||= proc { |remote| } @@inactivity_error_callback ||= proc { |remote| } + @@inactivity_warning_callback ||= proc { |remote| } self.update_procline EM.epoll EM.run do ProxyMachine::ClientConnection.start(host, port) @@ -126,6 +136,11 @@ end def proxy_inactivity_error(&block) ProxyMachine.set_inactivity_error_callback(&block) end + + def proxy_inactivity_warning(&block) + ProxyMachine.set_inactivity_warning_callback(&block) + end + end