Skip to main content

Client Utility API Reference

Utilities provided by PGOS, we would be happy if they could save you time. These APIs are not the only specified functions that must be used, as you can also implement them yourself. These APIs do not require nor support authentication, so you can use them before calling 'LoginPGOS'.

API List

APIDescription
HttpDownloadBuffDownload the specified URL using the http protocol.
HttpDownloadFileDownload the specified URL to local file using the http protocol.
CancelHttpDownloadCancel a requested download task.

API Details

HttpDownloadBuff

Download the specified URL using the http protocol.

/**
* Download the specified URL using the http protocol.
*
* @param url The url to download.
* @param save_callback This callback function gets called by PGOS as soon as there is data received that needs to be saved, and it may be called with zero bytes data if the transferred file is empty. It will be called in an ASYNCHRONOUS CHILD THREAD.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
* @return The id for the requested download task, zero if failed to create.
*/
int32_t HttpDownloadBuff(
const pgos::pstring& url,
PgosInterCallback<PgosBuffer> save_callback,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
urlconst std::string&The url to download.
save_callbackPgosInterCallback<PgosBuffer>This callback function gets called by PGOS as soon as there is data received that needs to be saved, and it may be called with zero bytes data if the transferred file is empty. It will be called in an ASYNCHRONOUS CHILD THREAD.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: int32_t

The id for the requested download task, zero if failed to create.

HttpDownloadFile

Download the specified URL to local file using the http protocol.

/**
* Download the specified URL to local file using the http protocol.
*
* @param url The url to download.
* @param save_path File path to write the data to. Pass in an ANSI-encoded path if the parameter type is not FString.
* @param progress_callback Data transfer progress callback, which will be called in an ASYNCHRONOUS CHILD THREAD.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
* @return The id for the requested download task, zero if failed to create.
*/
int32_t HttpDownloadFile(
const pgos::pstring& url,
const pgos::pstring& save_path,
PgosInterCallback<HttpDownloadProgressInfo> progress_callback,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
urlconst std::string&The url to download.
save_pathconst std::string&File path to write the data to. Pass in an ANSI-encoded path if the parameter type is not FString.
progress_callbackPgosInterCallback<HttpDownloadProgressInfo>Data transfer progress callback, which will be called in an ASYNCHRONOUS CHILD THREAD.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: int32_t

The id for the requested download task, zero if failed to create.

CancelHttpDownload

Cancel a requested download task.

/**
* Cancel a requested download task.
*
* @param task_id The download task id.
*/
void CancelHttpDownload(
int32_t task_id);

Parameters:

ParamTypeDescription
task_idint32_tThe download task id.

Return: void