Navigation

    VisionAppster.com

    VisionAppster Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. -mt-
    -
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    -mt-

    @-mt-

    0
    Reputation
    1
    Posts
    13
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    -mt- Follow

    Posts made by -mt-

    • RE: Initializing after restart

      Hi,
      you can use manager object's appStarted signal to reconnect the API when the app has been restarted:

      const myAppId = 'com.myapps.testapp/1';
      let apiCtrl;
      let api;
      let managerCtrl;
      let manager;
      
      async function connectApi()
      {
        if (apiCtrl)
          apiCtrl.disconnect(); // Note: this is currently needed first
        apiCtrl = new va.RemoteObject('/apis/' + myAppId);
        api = await apiCtrl.connect();
      }
      
      async function connect()
      {
        managerCtrl = new va.RemoteObject('/manager');
        manager = await managerCtrl.connect();
        manager.$appStarted.connect((appId) =>
        {
          if (appId === myAppId)
            connectApi();
        });
        connectApi();
      }
      

      Now, if you add connect() call before setInterval() call in your example, the api object should be always connected and ready to serve whenever the app is running.
      P.S. there seems to be also an issue that the previous remote api object instance needs to be disconnected first, or reconnecting won't work. We'll be looking at
      that also.

      posted in Engine
      -
      -mt-