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

VRequest Class

Class for performing web requests using UnityWebRequest

Overview

Static Fields

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

Object Data

Uri
uri[Get]
The URI of the current/last request.
string
payload[Get]
The data for PUT and POST requests. This will usually be set by child classes that have unencoded payloads.

Properties

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

Public Member Functions

delegate void
RequestProgressDelegate
( float progress )
delegate void
delegate void
RequestCompleteDelegate< TResult >
( TResult result,
string error )
VRequest
( RequestProgressDelegate onDownloadProgress,
RequestFirstResponseDelegate onFirstResponse )
A constructor that takes in download progress delegate & first response delegate
string
CleanUrl
( string url )
Adds 'file://' to url if no prefix is found
void
Cancel ( )
bool
Request
( UnityWebRequest unityRequest,
RequestCompleteDelegate< UnityWebRequest > onComplete )
Initialize with a request and an on completion callback
async Task< RequestCompleteResponse< TData > >
RequestAsync< TData >
( UnityWebRequest unityRequest,
Func< UnityWebRequest, TData > onDecode )
Initialize with a request and an on completion callback
bool
RequestFileHeaders
( Uri uri,
RequestCompleteDelegate< Dictionary< string, string >> onComplete )
Performs a header request on a uri
async Task< RequestCompleteResponse< Dictionary< string, string > > >
Performs a header request on a uri asynchronously
bool
RequestFile
( Uri uri,
RequestCompleteDelegate< byte[]> onComplete )
Performs a simple http header request
async Task< RequestCompleteResponse< byte[]> >
RequestFileAsync
( Uri uri )
Performs a simple http header request
async Task< RequestCompleteResponse< bool > >
RequestFileExistsAsync
( string checkPath )
Checks if a file exists at a specified location using async calls
bool
RequestFileExists
( string checkPath,
RequestCompleteDelegate< bool > onComplete )
Uses async method to check if file exists & return via the oncomplete method
bool
RequestFileDownload
( string downloadPath,
UnityWebRequest unityRequest,
RequestCompleteDelegate< bool > onComplete )
Download a file using a unityrequest
async Task< string >
RequestFileDownloadAsync
( string downloadPath,
UnityWebRequest unityRequest )
Download a file using a unityrequest
bool
RequestText
( UnityWebRequest unityRequest,
RequestCompleteDelegate< string > onComplete,
Performs a text request & handles the resultant text
async Task< RequestCompleteResponse< string > >
RequestTextAsync
( UnityWebRequest unityRequest,
Performs a text request async & returns the text along with any errors
bool
RequestJson< TData >
( UnityWebRequest unityRequest,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
Performs a request for text & decodes it into json
async Task< RequestCompleteResponse< TData > >
RequestJsonAsync< TData >
( UnityWebRequest unityRequest,
RequestCompleteDelegate< TData > onPartial )
Performs a request for text and decodes it into json asynchronously
bool
RequestJsonGet< TData >
( Uri uri,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
Perform a json get request with a specified uri
async Task< RequestCompleteResponse< TData > >
RequestJsonGetAsync< TData >
( Uri uri,
RequestCompleteDelegate< TData > onPartial )
Perform a json get request with a specified uri asynchronously
bool
RequestJsonPost< TData >
( Uri uri,
byte [] postData,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
Performs a json request by posting byte data
async Task< RequestCompleteResponse< TData > >
RequestJsonPostAsync< TData >
( Uri uri,
byte [] postData,
RequestCompleteDelegate< TData > onPartial )
Performs a json request by posting byte data asynchronously
bool
RequestJsonPost< TData >
( Uri uri,
string postText,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
Performs a json request by posting a string
async Task< RequestCompleteResponse< TData > >
RequestJsonPostAsync< TData >
( Uri uri,
string postText,
RequestCompleteDelegate< TData > onPartial )
Performs a json request by posting a string asynchronously
bool
RequestJsonPut< TData >
( Uri uri,
byte [] putData,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
Performs a json put request with byte data
async Task< RequestCompleteResponse< TData > >
RequestJsonPutAsync< TData >
( Uri uri,
byte [] putData,
RequestCompleteDelegate< TData > onPartial )
Performs a json put request with byte data asynchronously
bool
RequestJsonPut< TData >
( Uri uri,
string putText,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
Performs a json put request with text
async Task< RequestCompleteResponse< TData > >
RequestJsonPutAsync< TData >
( Uri uri,
string putText,
RequestCompleteDelegate< TData > onPartial )
Performs a json put request with text asynchronously
GetAudioDecoder
( AudioType audioType,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Instantiate an audio decoder based on the audio type to allow for complex streaming scenarios
bool
RequestAudioStream
( IAudioClipStream clipStream,
Uri uri,
RequestCompleteDelegate< IAudioClipStream > onClipStreamReady,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, uri & completion delegate
bool
RequestAudioStream
( IAudioClipStream clipStream,
UnityWebRequest unityRequest,
RequestCompleteDelegate< IAudioClipStream > onClipStreamReady,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, web request & completion delegate
RequestAudioStreamAsync
( IAudioClipStream clipStream,
Uri uri,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, uri & completion delegate
RequestAudioStreamAsync
( IAudioClipStream clipStream,
UnityWebRequest unityRequest,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, web request & completion delegate

Object Data

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

Static Public Member Functions

static string
GetSpecificRequestError
( UnityWebRequest request )
static string
GetAudioExtension
( AudioType audioType )
Get audio extension from audio type
static string
GetAudioExtension
( AudioType audioType,
bool textStream )
Get audio extension from audio type
static Type
GetAudioDecoderType
( AudioType audioType )
Returns the IAudioDecoder type that works best with the specified AudioType for the current platform.
static bool
CanDecodeAudio
( AudioType audioType )
Whether or not a specific audio type can be decoded
static bool
CanStreamAudio
( AudioType audioType )
Whether or not audio can be streamed for a specific audio type

Details

Public Statics

int Meta.WitAi.Requests.VRequest.MaxConcurrentRequests
Will only start new requests if there are less than this number If <= 0, then all requests will run immediately

Object Data

Uri Meta.WitAi.Requests.VRequest.uri
The URI of the current/last request.
string Meta.WitAi.Requests.VRequest.payload
The data for PUT and POST requests. This will usually be set by child classes that have unencoded payloads.

Properties

int Meta.WitAi.Requests.VRequest.Timeout
Timeout in seconds
bool Meta.WitAi.Requests.VRequest.IsPerforming
If request is currently being performed
bool Meta.WitAi.Requests.VRequest.HasFirstResponse
If first response has been received
bool Meta.WitAi.Requests.VRequest.IsStreamReady
If the download handler incorporates IVRequestStreamable & IsStreamReady
bool Meta.WitAi.Requests.VRequest.IsComplete
Whether or not the completion delegate has been called
int Meta.WitAi.Requests.VRequest.ResponseCode
Response Code if applicable
string Meta.WitAi.Requests.VRequest.ResponseError
Response error
float Meta.WitAi.Requests.VRequest.UploadProgress
Current progress for get requests
float Meta.WitAi.Requests.VRequest.DownloadProgress
Current progress for download

Member Functions

delegate void Meta.WitAi.Requests.VRequest.RequestProgressDelegate
( float progress )
No description available.
delegate void Meta.WitAi.Requests.VRequest.RequestFirstResponseDelegate ( )
No description available.
delegate void Meta.WitAi.Requests.VRequest.RequestCompleteDelegate< TResult >
( TResult result,
string error )
No description available.
Meta.WitAi.Requests.VRequest.VRequest
( RequestProgressDelegate onDownloadProgress,
RequestFirstResponseDelegate onFirstResponse )
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
virtual string Meta.WitAi.Requests.VRequest.CleanUrl
( string url )
Adds 'file://' to url if no prefix is found
virtual void Meta.WitAi.Requests.VRequest.Cancel ( )
No description available.
virtual bool Meta.WitAi.Requests.VRequest.Request
( UnityWebRequest unityRequest,
RequestCompleteDelegate< UnityWebRequest > onComplete )
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
virtual async Task<RequestCompleteResponse<TData> > Meta.WitAi.Requests.VRequest.RequestAsync< TData >
( UnityWebRequest unityRequest,
Func< UnityWebRequest, TData > onDecode )
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
bool Meta.WitAi.Requests.VRequest.RequestFileHeaders
( Uri uri,
RequestCompleteDelegate< Dictionary< string, string >> onComplete )
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
async Task<RequestCompleteResponse<Dictionary<string, string> > > Meta.WitAi.Requests.VRequest.RequestFileHeadersAsync
( Uri uri )
Performs a header request on a uri asynchronously
Parameters
uri
The uri to perform the request on
Returns
Returns the header
bool Meta.WitAi.Requests.VRequest.RequestFile
( Uri uri,
RequestCompleteDelegate< byte[]> onComplete )
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
async Task<RequestCompleteResponse<byte[]> > Meta.WitAi.Requests.VRequest.RequestFileAsync
( Uri uri )
Performs a simple http header request
Parameters
uri
Uri to get a file
Returns
False if cannot begin request
async Task<RequestCompleteResponse<bool> > Meta.WitAi.Requests.VRequest.RequestFileExistsAsync
( string checkPath )
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
bool Meta.WitAi.Requests.VRequest.RequestFileExists
( string checkPath,
RequestCompleteDelegate< bool > onComplete )
Uses async method to check if file exists & return via the oncomplete method
Parameters
checkPath
The local file path to be checked
bool Meta.WitAi.Requests.VRequest.RequestFileDownload
( string downloadPath,
UnityWebRequest unityRequest,
RequestCompleteDelegate< bool > onComplete )
Download a file using a unityrequest
Parameters
unityRequest
The unity request to add a download handler to
onComplete
Called once download has completed
async Task<string> Meta.WitAi.Requests.VRequest.RequestFileDownloadAsync
( string downloadPath,
UnityWebRequest unityRequest )
Download a file using a unityrequest
Parameters
unityRequest
The unity request to add a download handler to
bool Meta.WitAi.Requests.VRequest.RequestText
( UnityWebRequest unityRequest,
RequestCompleteDelegate< string > onComplete,
Performs a text request & handles the resultant text
Parameters
unityRequest
The unity request performing the post or get
onComplete
The delegate upon completion
async Task<RequestCompleteResponse<string> > Meta.WitAi.Requests.VRequest.RequestTextAsync
( UnityWebRequest unityRequest,
Performs a text request async & returns the text along with any errors
Parameters
unityRequest
The unity request performing the post or get
bool Meta.WitAi.Requests.VRequest.RequestJson< TData >
( UnityWebRequest unityRequest,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
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
async Task<RequestCompleteResponse<TData> > Meta.WitAi.Requests.VRequest.RequestJsonAsync< TData >
( UnityWebRequest unityRequest,
RequestCompleteDelegate< TData > onPartial )
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
bool Meta.WitAi.Requests.VRequest.RequestJsonGet< TData >
( Uri uri,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
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
async Task<RequestCompleteResponse<TData> > Meta.WitAi.Requests.VRequest.RequestJsonGetAsync< TData >
( Uri uri,
RequestCompleteDelegate< TData > onPartial )
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
bool Meta.WitAi.Requests.VRequest.RequestJsonPost< TData >
( Uri uri,
byte [] postData,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
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
async Task<RequestCompleteResponse<TData> > Meta.WitAi.Requests.VRequest.RequestJsonPostAsync< TData >
( Uri uri,
byte [] postData,
RequestCompleteDelegate< TData > onPartial )
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
bool Meta.WitAi.Requests.VRequest.RequestJsonPost< TData >
( Uri uri,
string postText,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
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
async Task<RequestCompleteResponse<TData> > Meta.WitAi.Requests.VRequest.RequestJsonPostAsync< TData >
( Uri uri,
string postText,
RequestCompleteDelegate< TData > onPartial )
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
bool Meta.WitAi.Requests.VRequest.RequestJsonPut< TData >
( Uri uri,
byte [] putData,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
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
async Task<RequestCompleteResponse<TData> > Meta.WitAi.Requests.VRequest.RequestJsonPutAsync< TData >
( Uri uri,
byte [] putData,
RequestCompleteDelegate< TData > onPartial )
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
bool Meta.WitAi.Requests.VRequest.RequestJsonPut< TData >
( Uri uri,
string putText,
RequestCompleteDelegate< TData > onComplete,
RequestCompleteDelegate< TData > onPartial )
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
async Task<RequestCompleteResponse<TData> > Meta.WitAi.Requests.VRequest.RequestJsonPutAsync< TData >
( Uri uri,
string putText,
RequestCompleteDelegate< TData > onPartial )
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
virtual IAudioDecoder Meta.WitAi.Requests.VRequest.GetAudioDecoder
( AudioType audioType,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Instantiate an audio decoder based on the audio type to allow for complex streaming scenarios
Parameters
audioType
Audio decoder type allowed
textStream
Whether or not text will be returned within the stream
onJsonDecoded
The text decode callback which will be called multiple times
Returns
Instantiated audio decoder
bool Meta.WitAi.Requests.VRequest.RequestAudioStream
( IAudioClipStream clipStream,
Uri uri,
RequestCompleteDelegate< IAudioClipStream > onClipStreamReady,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, uri & completion delegate
Parameters
clipStream
The clip audio stream handler, one must be provided
uri
The url to be called
onClipStreamReady
Called when the clip is ready for playback or has failed to load
audioType
The audio type requested (Wav, MP3, etc.)
audioStream
Whether or not audio should be streamed
textStream
Whether or not text will be returned within the stream
onJsonDecoded
The text decode callback which will be called multiple times
bool Meta.WitAi.Requests.VRequest.RequestAudioStream
( IAudioClipStream clipStream,
UnityWebRequest unityRequest,
RequestCompleteDelegate< IAudioClipStream > onClipStreamReady,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, web request & completion delegate
Parameters
clipStream
The clip audio stream handler, one must be provided
unityRequest
The unity request to add a download handler to
onClipStreamReady
Called when the clip is ready for playback or has failed to load
audioType
The audio type requested (Wav, MP3, etc.)
audioStream
Whether or not audio should be streamed
textStream
Whether or not text will be returned within the stream
onJsonDecoded
The text decode callback which will be called multiple times
async Task<RequestCompleteResponse<IAudioClipStream> > Meta.WitAi.Requests.VRequest.RequestAudioStreamAsync
( IAudioClipStream clipStream,
Uri uri,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, uri & completion delegate
Parameters
clipStream
The clip audio stream handler, one must be provided
uri
The url to be called
audioType
The audio type requested (Wav, MP3, etc.)
audioStream
Whether or not audio should be streamed
textStream
Whether or not text will be returned within the stream
onJsonDecoded
The text decode callback which will be called multiple times
Returns
Returns the resultant audio clip stream
async Task<RequestCompleteResponse<IAudioClipStream> > Meta.WitAi.Requests.VRequest.RequestAudioStreamAsync
( IAudioClipStream clipStream,
UnityWebRequest unityRequest,
AudioType audioType,
bool audioStream,
bool textStream,
AudioJsonDecodeDelegate onJsonDecoded )
Request audio clip with audio data, web request & completion delegate
Parameters
clipStream
The clip audio stream handler, one must be provided
unityRequest
The unity request to add a download handler to
audioType
The audio type requested (Wav, MP3, etc.)
audioStream
Whether or not audio should be streamed
textStream
Whether or not text will be returned within the stream
onJsonDecoded
The text decode callback which will be called multiple times
Returns
Returns the resultant audio clip stream

Object Data

virtual void Meta.WitAi.Requests.VRequest.Setup
( UnityWebRequest unityRequest )
No description available.
virtual Dictionary<string, string> Meta.WitAi.Requests.VRequest.GetHeaders ( )
No description available.
virtual void Meta.WitAi.Requests.VRequest.Begin ( )
No description available.
virtual bool Meta.WitAi.Requests.VRequest.IsRequestComplete ( )
No description available.
virtual void Meta.WitAi.Requests.VRequest.Update ( )
No description available.
virtual void Meta.WitAi.Requests.VRequest.Unload ( )
No description available.

Static Member Functions

static string Meta.WitAi.Requests.VRequest.GetSpecificRequestError
( UnityWebRequest request )
No description available.
static string Meta.WitAi.Requests.VRequest.GetAudioExtension
( AudioType audioType )
Get audio extension from audio type
Parameters
audioType
The specified audio type
Returns
Audio extension without period.
static string Meta.WitAi.Requests.VRequest.GetAudioExtension
( AudioType audioType,
bool textStream )
Get audio extension from audio type
Parameters
audioType
The specified audio type
textStream
Whether data includes text
Returns
Audio extension without period.
static Type Meta.WitAi.Requests.VRequest.GetAudioDecoderType
( AudioType audioType )
Returns the IAudioDecoder type that works best with the specified AudioType for the current platform.
static bool Meta.WitAi.Requests.VRequest.CanDecodeAudio
( AudioType audioType )
Whether or not a specific audio type can be decoded
static bool Meta.WitAi.Requests.VRequest.CanStreamAudio
( AudioType audioType )
Whether or not audio can be streamed for a specific audio type
Did you find this page helpful?
Thumbs up icon
Thumbs down icon