1 Reply Latest reply on Jul 25, 2012 4:19 PM by drkstr_1

    Invoke service

    Zolotoj Level 3

      I am trying to get the following working: We are using remote objects to get/save data. When server session expires the user gets a prompt to relogin. After that I am issuing the following command: lastServerRequest.currentTarget.invokeService(lastServerRequest.currentTarget.request); where lastServerRequest is RemoteServiceEvent.  It does work but I am having a problem with calling a callback function when it was specified.   Any idea?

        • 1. Re: Invoke service
          drkstr_1 Level 4

          I'm not entirely sure what your trying to do there, but it sounds like you want to recall the failed service method after the user has logged back in. For this I would implement some kind of Command Pattern. Basically it just means that instead of calling a method, you put all the info in a single class that has some kind of execute() method. This allows you to store the object instance and invoke the "command" at a time of your choosing.

           

          //code may contain typos

          public class DoStuffCommand

          {

                    public var foo:String;

           

                    public var bar:String;

           

                    public resultHandler:Function;

           

                    public faultHandler:Function;

           

                    public function execute():void

                    {

                              var ro:RemoteObject = new RemoteObject("my-destination");

                              var token:AsynToken = ro.doStuff(this.foo, this.bar);

                              token.addResponder( new Responder(this.resultHandler, this.faultHandler));

                    }

          }

           

           

          This concept should be tailored for your specific use case. More info is needed to provide any specific advice.