API reference
API reference
Select your platform
No SDKs available
No versions available

VRequest Class

Class for performing web requests using UnityWebRequest

Public Statics

Will only start new requests if there are less than this number If <= 0, then all requests will run immediately

Protected Fields

The URI of the current/last request.
The data for PUT and POST requests. This will usually be set by child classes that have unencoded payloads.

Properties

Timeout in seconds
If request is currently being performed
If first response has been received
If the download handler incorporates IVRequestStreamable & IsStreamReady
Whether or not the completion delegate has been called
Response Code if applicable
Response error
Current progress for get requests
Current progress for download

Member Functions

delegate void RequestProgressDelegate
( float progress )
delegate void RequestFirstResponseDelegate ( )
delegate void RequestCompleteDelegate< TResult >
( TResult result,
string error )
A constructor that takes in download progress delegate & first response delegate
Parameters
onDownloadProgress
The callback for progress related to downloading
onFirstResponse
The callback for the first response of data from a request
Adds 'file://' to url if no prefix is found
virtual void Cancel ( )
Initialize with a request and an on completion callback
Parameters
unityRequest
The unity request to be performed
onComplete
The callback on completion, returns the request & error string
Returns
False if the request cannot be performed
Initialize with a request and an on completion callback
Parameters
unityRequest
The unity request to be performed
onDecode
A function to be performed to async decode all request data
Returns
Any errors encountered during the request
Performs a header request on a uri
Parameters
uri
The uri to perform the request on
onComplete
A completion callback that includes the headers
Returns
Performs a header request on a uri asynchronously
Parameters
uri
The uri to perform the request on
Returns
Returns the header
Performs a simple http header request
Parameters
uri
Uri to get a file
onComplete
Called once file data has been loaded
Returns
False if cannot begin request
Performs a simple http header request
Parameters
uri
Uri to get a file
Returns
False if cannot begin request
Checks if a file exists at a specified location using async calls
Parameters
checkPath
The local file path to be checked
Returns
An error if found
Uses async method to check if file exists & return via the oncomplete method
Parameters
checkPath
The local file path to be checked
Download a file using a unityrequest
Parameters
unityRequest
The unity request to add a download handler to
onComplete
Called once download has completed
Download a file using a unityrequest
Parameters
unityRequest
The unity request to add a download handler to
Performs a text request & handles the resultant text
Parameters
unityRequest
The unity request performing the post or get
onComplete
The delegate upon completion
Performs a text request async & returns the text along with any errors
Parameters
unityRequest
The unity request performing the post or get
Performs a request for text & decodes it into json
Parameters
unityRequest
The unity request performing the post or get
onComplete
The delegate upon completion
Others
TData
The struct or class to be deserialized to
Returns
False if the request cannot be performed
Performs a request for text and decodes it into json asynchronously
Parameters
unityRequest
The unity request performing the post or get
Others
TData
The struct or class to be deserialized to
Returns
RequestCompleteResponse with parsed data & error if applicable
Perform a json get request with a specified uri
Parameters
uri
The uri to be requested
onComplete
The delegate upon completion
Others
TData
The struct or class to be deserialized to
Returns
False if the request cannot be performed
Perform a json get request with a specified uri asynchronously
Parameters
uri
The uri to be requested
Others
TData
The struct or class to be deserialized to
Returns
RequestCompleteResponse with parsed data & error if applicable
Performs a json request by posting byte data
Parameters
uri
The uri to be requested
postData
The data to be uploaded
onComplete
The delegate upon completion
Others
TData
The struct or class to be deserialized to
Returns
False if the request cannot be performed
Performs a json request by posting byte data asynchronously
Parameters
uri
The uri to be requested
postData
The data to be uploaded
Others
TData
The struct or class to be deserialized to
Returns
RequestCompleteResponse with parsed data & error if applicable
Performs a json request by posting a string
Parameters
uri
The uri to be requested
postText
The string to be uploaded
onComplete
The delegate upon completion
Others
TData
The struct or class to be deserialized to
Returns
False if the request cannot be performed
Performs a json request by posting a string asynchronously
Parameters
uri
The uri to be requested
postText
The string to be uploaded
Others
TData
The struct or class to be deserialized to
Returns
RequestCompleteResponse with parsed data & error if applicable
Performs a json put request with byte data
Parameters
uri
The uri to be requested
putData
The data to be uploaded
onComplete
The delegate upon completion
Others
TData
The struct or class to be deserialized to
Returns
False if the request cannot be performed
Performs a json put request with byte data asynchronously
Parameters
uri
The uri to be requested
putData
The data to be uploaded
Others
TData
The struct or class to be deserialized to
Returns
RequestCompleteResponse with parsed data & error if applicable
Performs a json put request with text
Parameters
uri
The uri to be requested
putText
The text to be uploaded
onComplete
The delegate upon completion
Others
TData
The struct or class to be deserialized to
Returns
False if the request cannot be performed
Performs a json put request with text asynchronously
Parameters
uri
The uri to be requested
putText
The text to be uploaded
Others
TData
The struct or class to be deserialized to
Returns
RequestCompleteResponse with parsed data & error if applicable
Instantiate an audio decoder based on the audio type to allow for complex streaming scenarios
Parameters
audioType
Audio decoder type allowed
includeJson
Whether or not json will be returned within the stream
onJsonDecoded
The json decode callback which will be called multiple times
Request audio clip with uri, audio type, sample decoded delegate & completion delegate
Parameters
uri
The url to be called
audioType
The audio type requested (Wav, MP3, etc.)
includesJson
Whether or not json will be embedded within the audio stream.
onSamplesDecoded
Called one or more times as audio samples are decoded.
onJsonDecoded
Called one or more times as json data is decoded.
onComplete
Called when the audio request has completed
Request audio clip with web request, audio type, whether audio includes json data, callback delegates & completion delegate
Parameters
unityRequest
The unity request to add a download handler to
audioType
The audio type requested (Wav, MP3, etc.)
includesJson
Whether or not json will be embedded within the audio stream.
onSamplesDecoded
Called one or more times as audio samples are decoded.
onJsonDecoded
Called one or more times as json data is decoded.
onComplete
Called when the audio request has completed

Protected Functions

virtual void Setup
( UnityWebRequest unityRequest )
virtual Dictionary< string, string > GetHeaders ( )
virtual void Begin ( )
virtual bool IsRequestComplete ( )
virtual void Update ( )
virtual void Unload ( )

Static Member Functions

static string GetSpecificRequestError
( UnityWebRequest request )
Get audio extension from audio type
Parameters
audioType
The specified audio type
Returns
Audio extension without period.
Get audio extension from audio type
Parameters
audioType
The specified audio type
textStream
Whether data includes text
Returns
Audio extension without period.
Returns the IAudioDecoder type that works best with the specified AudioType for the current platform.
Whether or not a specific audio type can be decoded
Whether or not audio can be streamed for a specific audio type
Did you find this page helpful?
Thumbs up icon
Thumbs down icon