Type alias tSetProxyCallback

tSetProxyCallback: ((pUrl: string | undefined) => void)

Type declaration

    • (pUrl: string | undefined): void
    • This type is a callback that must be called inside or after the user defined tChooseProxyCallback.

      This is used in the open data session procedure, initiated by createDataSession and openDataSession.

      This callback actually continues the open data session procedure. If not called, the open data session procedure will never terminate.

      /** 
      * 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

      • pUrl: string | undefined

      Returns void