Type alias tChooseProxyCallback

tChooseProxyCallback: ((pProxies: ProxyChoiceInterface[], pSetProxyCallback: tSetProxyCallback) => void)

Type declaration

    • (pProxies: ProxyChoiceInterface[], pSetProxyCallback: tSetProxyCallback): void
    • This type is a user defined callback that is set in createDataSession function.

      When openDataSession is called, this callback will be called asynchronously. The callback may process the list of input proxies to choose the most appropriate one and call pSetProxyCallback to continue the open data session procedure.

      /** 
      * Sample to illustrate the use of the the choice of a proxy for the open data procedure (DataSessionInterface).
      */
      import {
      tChooseProxyCallback, ProxyChoiceInterface, tSetProxyCallback, InfiniteCacheInterface,
      DirectorySessionInterface, DataSessionInterface, DataSessionInterfaceSignal, tListenerCallback
      } from 'generated/documentation/appinfiniteapi';

      // lDirectorySession has been created previously, the user is now logged in and knows the 3djuump infinite available builds.
      let lDirectorySession : DirectorySessionInterface;
      // lInfiniteCache may has been created previously (not required)
      let lInfiniteCache : InfiniteCacheInterface | undefined;
      // the build id to connect to
      let lBuildId : string;
      // the callback that will be called when the DMU has finished loading
      let myDMULoadedCallback : tListenerCallback;

      // very simple callback, choose the first available proxy
      const lChooseProxyCallback : tChooseProxyCallback = (pProxies: Array<ProxyChoiceInterface>, pFinishLoadingCallback : tSetProxyCallback) : void =>
      {
      let i : number;
      const lLength : number = pProxies.length;
      // output all proxies
      for (i = 0; i < lLength; ++i)
      {
      console.log(pProxies[0].getLabel());
      }
      // DO NOT forget to call pFinishLoadingCallback, if not, the DMU loading process will never finish
      // and with the url of the chosen proxy
      pFinishLoadingCallback(pProxies[0].getUrl());
      }

      // connect the data session to the build, the proxy choice is asynchronous, and will
      // trigger lChooseProxyCallback when the dev chooses a proxy
      const lDataSession : DataSessionInterface | undefined = lDirectorySession.createDataSession(lBuildId, lInfiniteCache, lChooseProxyCallback);
      if (!lDataSession)
      {
      console.log('something weird happened, the directory session cannot create a data session');
      console.log('Perhaps the directory session is already closed, or closing, or the login procedure failed');
      }
      else
      {
      // we sure want to be notified when the DMU has finished loading
      lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, myDMULoadedCallback);

      // and GO => open the data session
      if (!lDataSession.openDataSession())
      {
      console.log('something weird happened, this session has already been used, this is not a freshly created one');
      }

      // and wait for myDMULoadedCallback to be called
      }

      Please refer to [DirectorySessionInterface](../interfaces/DirectorySessionInterface.html) for more information.
      Sessions

      See

      Parameters

      Returns void