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
| API | Description |
|---|---|
| HttpDownloadBuff | Download the specified URL using the http protocol. |
| HttpDownloadFile | Download the specified URL to local file using the http protocol. |
| CancelHttpDownload | Cancel 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:
| Param | Type | Description |
|---|---|---|
| url | const std::string& | The url to download. |
| save_callback | PgosInterCallback<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_callback | PgosCallback | The 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:
| Param | Type | Description |
|---|---|---|
| url | const std::string& | The url to download. |
| save_path | const std::string& | File path to write the data to. Pass in an ANSI-encoded path if the parameter type is not FString. |
| progress_callback | PgosInterCallback<HttpDownloadProgressInfo> | Data transfer progress callback, which will be called in an ASYNCHRONOUS CHILD THREAD. |
| result_callback | PgosCallback | The 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:
| Param | Type | Description |
|---|---|---|
| task_id | int32_t | The download task id. |
Return: void