WebRequestHandler acts as the counterpart of a WebRequestHandler2 Component in Unity. When the Component is started, an instance of this class is created by UnityUtil and attached to the unityInstance. This reference is used by functions in the WebRequestHandler2.jslib plug-in in Unity to make calls directly from the viewer.

Hierarchy

  • ExternalWebRequestHandler

Constructors

Properties

apiHost: string

An object providing an API to a cache

gameObjectName: string

The gameObject which should be passed to SendMessage when making the callbacks to the viewer

requests: any

Resources for in-progress get requests

unityInstance: any

The Unity Instance created by the loader; this is used for SendMessage

Methods

  • Aborts the request. This will only take effect if sendOnWebResponse has not already been called.

    Parameters

    • id: number

    Returns void

  • Queue a request with the specified id. The id must be registered immediately, in case the viewer then calls abortRequest. The actual response is retrieved asynchronously over some time.

    Parameters

    • id: number
    • url: string
    • cache: Boolean

    Returns void

  • Copies the data returned from a get request into the heap at offset. Once this is done the local resources should be released by calling releaseTransaction.

    Parameters

    • id: number
    • offset: number

    Returns void

  • Converts the data returned from a get request into a string and returns it. The plugin will allocate an unmanaged buffer for the string and copy it into it.

    Parameters

    • id: number

    Returns string

  • Given a local URI that can also act as a cache key, return a fully qualified URI that will return the resource from .io

    Parameters

    • url: any

    Returns string

  • Should direct to the cache object's read function. If the cache is disabled, returning an empty fulfilled promise will cause the request to be passed onto the web. The caller can skip the cache regardless of its state by passing false for the cache parameter.

    Parameters

    • url: any
    • cache: any

    Returns Promise<ArrayBuffer>

  • Releases any resources associated with an existing request. Not all oprations will have resources. If an invalid id is passed in, this method does nothing.

    Parameters

    • id: number

      The transaction id whose resources to dispose of

    Returns void

  • Initialises this handler for an instance of Unity. Should be called by the viewer once it is fully initialised.

    Parameters

    • unityInstance: any
    • gameObjectName: string

    Returns boolean

Generated using TypeDoc