lib/transporter/transporter.rb in rsence-2.0.0.1.pre vs lib/transporter/transporter.rb in rsence-2.0.0.2.pre

- old
+ new

@@ -31,38 +31,19 @@ def initialize @config = ::RSence.config[:transporter_conf] @valuemanager = ValueManager.new @sessions = SessionManager.new( self ) - @plugins = PluginManager.new( ::RSence.config[:plugin_paths], self, $DEBUG_MODE ) + @plugins = PluginManager.new( ::RSence.config[:plugin_paths], self, RSence.args[:autoreload] ) if RSence.launch_pid != Process.pid Process.kill( 'TERM', RSence.launch_pid ) end end def servlet( request_type, request, response ) broker_urls = ::RSence.config[:broker_urls] uri = request.fullpath - # if $DEBUG_MODE and uri == $config[:index_html][:respond_address] and request_type == :get - # unless ARGV.include?('-no-rescan') or ARGV.include?('--no-rescan') - # puts "Reloading plugins." - # if RSence.args[:say] - # Thread.new do - # Thread.pass - # system('say "Reloading plugins."') - # end - # end - # @plugins.rescan - # puts "Plugins reloaded." - # if RSence.args[:say] - # Thread.new do - # Thread.pass - # system('say "Plugins reloaded."') - # end - # end - # end - # end if request_type == :post ## /x handles xhr without cookies if uri == broker_urls[:x] and @sessions.accept_requests xhr( request, response, { :cookies => true, :servlet => false } ) @@ -72,26 +53,17 @@ xhr( request, response, { :cookies => true, :servlet => false } ) return true else session = {} return @plugins.match_servlet( request_type, request, response, session ) - ## /SOAP handles SOAP Requests - # elsif uri == broker_urls[:soap] - # soap( request, response ) - # return true end else session = {} return @plugins.match_servlet( request_type, request, response, session ) end end - ## handles incoming SOAP requests - # def soap(request, response) - # PluginManager.soap( request, response ) - # end - # wrapper for the session manager stop client functionality def xhr_error_handler(msg,err_name,err_extra_descr='') @sessions.stop_client_with_message( msg, @config[:messages][err_name][:title], @config[:messages][err_name][:descr]+err_extra_descr, @@ -99,13 +71,13 @@ ) end # wrapper for tracebacks in xhr def xhr_traceback_handler(e,err_descr='Transporter::UnspecifiedError') - puts "=="*40 if $DEBUG_MODE + puts "=="*40 if RSence.args[:debug] puts err_descr - if $DEBUG_MODE + if RSence.args[:debug] puts "--"*40 puts e.message puts " #{e.backtrace.join("\n ")}" puts "=="*40 end @@ -129,11 +101,11 @@ # If the client encounters an error, display error message if request.query.has_key?('err_msg') response_success = false client_error_msg = request.query['err_msg'].inspect - puts "\nCLIENT ERROR:\n#{client_error_msg}\n" if $DEBUG_MODE + puts "\nCLIENT ERROR:\n#{client_error_msg}\n" if RSence.args[:debug] xhr_error_handler(msg,:client_error,client_error_msg) end # If the session is valid, continue: if msg.ses_valid and response_success @@ -142,14 +114,14 @@ # be changed from /hello to /x to prevent further cookie juggling. if options[:cookies] and not options[:servlet] msg.reply("COMM.Transporter.url=#{::RSence.config[:broker_urls][:x].to_json};") end - # Appends a 'new session.' message for new sessions in $DEBUG_MODE: - puts "new session." if msg.new_session and $DEBUG_MODE - puts "restored session." if msg.restored_session and $DEBUG_MODE - puts "clone source." if msg.cloned_targets and $DEBUG_MODE - puts "clone target." if msg.cloned_source and $DEBUG_MODE + # Appends a 'new session.' message for new sessions in RSence.args[:verbose]: + puts "new session." if msg.new_session and RSence.args[:verbose] + puts "restored session." if msg.restored_session and RSence.args[:verbose] + puts "clone source." if msg.cloned_targets and RSence.args[:verbose] + puts "clone target." if msg.cloned_source and RSence.args[:verbose] ## Pass the client XML to the value manager if request.query.has_key?( 'values' ) syncdata_str = request.query[ 'values' ] begin