lib/transporter/transporter.rb in rsence-2.0.0.10.pre vs lib/transporter/transporter.rb in rsence-2.0.0.11

- old
+ new

@@ -1,43 +1,52 @@ -#-- ## RSence # Copyright 2008 Riassence Inc. # http://riassence.com/ # # You should have received a copy of the GNU General Public License along # with this software package. If not, contact licensing@riassence.com ## - #++ -module RSence +# ValueManager synchronizes value objects +require 'values/valuemanager' - # Transporter handles incoming requests targeted at RSence - # and distributes calls and data accordingly. - class Transporter - - # ValueManager syncronizes value objects - require 'values/valuemanager' - - # SessionManager creates, validates, stores and expires sessions - require 'session/sessionmanager' +# SessionManager creates, validates, stores and expires sessions +require 'session/sessionmanager' - # PluginManager handles all the plugins - require 'plugins/pluginmanager' +# PluginManager handles all the plugins +require 'plugins/pluginmanager' + + +module RSence - attr_accessor :valuemanager, :sessions, :plugins - + # Transporter handles incoming requests targeted at RSence and distributes calls and data accordingly. It's called via {Broker}. + # @see Broker + class Transporter + + # The single instance of the {ValueManager} + # @return [ValueManager] + attr_accessor :valuemanager + + # The single instance of the {SessionManager} + # @return [SessionManager] + attr_accessor :sessions + + # The main instance of the {PluginManager} + # @return [PluginManager] + attr_accessor :plugins + def initialize - @config = ::RSence.config[:transporter_conf] + @config = RSence.config[:transporter_conf] @accept_req = false @valuemanager = ValueManager.new @sessions = SessionManager.new( self ) core_pkgs = { :core => [:transporter, :session_storage, :session_manager, :value_manager] } @plugins = PluginManager.new( - ::RSence.config[:plugin_paths], + RSence.config[:plugin_paths], self, RSence.args[:autoupdate], false, core_pkgs[:core], core_pkgs @@ -68,11 +77,11 @@ @plugins.shutdown @sessions.shutdown end def servlet( request_type, request, response ) - broker_urls = ::RSence.config[:broker_urls] + broker_urls = RSence.config[:broker_urls] uri = request.fullpath if request_type == :post ## /x handles xhr without cookies if uri == broker_urls[:x] and @sessions.accept_requests @@ -114,11 +123,11 @@ end ## handles incoming XMLHttpRequests from the browser def xhr(request, response, options = { :cookies => false, :servlet => false } ) - session_conf = ::RSence.config[:session_conf] + session_conf = RSence.config[:session_conf] options[:cookies] = false unless options.has_key?(:cookies) if session_conf[:session_cookies] and session_conf[:trust_cookies] options[:cookies] = true @@ -141,10 +150,10 @@ if msg.ses_valid and response_success # If cookies are true, it means the url base needs to # 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};") + msg.reply("COMM.Transporter.url=#{RSence.config[:broker_urls][:x].to_json};") end # 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]