4 Replies Latest reply on Nov 12, 2009 5:58 AM by DMonday

    Session expires on module loading event

    DMonday

      Hi everyone,

       

      I have a problem associated with module loading process. There is a situation when I'm trying to load a new module into main application and session has been expired. I wonder if there is any way to catch a result from server, cause server returns me an XML, if the session of the current user has been expired, and as I understand IModuleInfo is waiting for a module.

       

      The code:

       

      var _particleInfo:IModuleInfo = ModuleManager.getModule(url);
      _particleInfo.addEventListener(ModuleEvent.PROGRESS, onModuleProgress);
      _particleInfo.addEventListener(ModuleEvent.READY, onModuleReady);
      _particleInfo.addEventListener(ModuleEvent.ERROR, onModuleError);
      _particleInfo.load();

       

      This is how I load the module.

       

      But when the session has been expired I can get only into onModuleProgress function and I also can see that I've got my session-expired XML size as a bytesTotal and in the fiddler as a responce I can see it, and here is a problem:

       

      All these functions get only one param ModuleEvent and there is no information about the responce, so I could parse it.

       

      Its there are any ideas?

       

      P.S. I have a solution, but in my solution I need to refactor back-end, but I don't wont it right now

        • 1. Re: Session expires on module loading event
          Flex harUI Adobe Employee

          I don't understand the issue.  You don't want a module to load if the session expires?  Just ignore it on onModuleReady.

           

          BTW, the way you've written the code, you might not ever get a READY event because if the only reference to IModuleInfo is in a local variable there is nothing to keep it from getting garbage collected and the initialization of the module can trigger a garbage collection pass.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Session expires on module loading event
            DMonday Level 1

            Thank you, for the answer I'll try to rephrase my issue.

             

            I'm developing a RIA, and there is a nice security layer on back-end, so if you are not logined you can get only specific xml document. So the problem is that when user is working with this RIA he or she can get out of session time and in this moment he or she can ask server to get a new module. And when it happens instead of module you've got an xml.

             

            If it's still a problem to understand my question I'll try to make a simple example.

             

            Imagen that you have a ModuleLoader: <mx:ModuleLoader url="ColumnChartModule.swf"/> and instead of swf file I got xml cause the session is expired.

             

            So the question is how I can get this xml?

            • 3. Re: Session expires on module loading event
              Flex harUI Adobe Employee

              I think you are saying that the server will not serve the SWF and serve an XML file instead.  If that's the case, instead of using ModuleLoader, try using URLLoader.  If you get a ByteArray instead of XML then you probably got the SWF and can use ModuleManager.load() to load the module as a ByteArray.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: Session expires on module loading event
                DMonday Level 1

                Thanks man. It works fine with URLLoader