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 SaveCallback 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 ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
* @return The id for the requested download task, zero if failed to create.
*/
int32 HttpDownloadBuff(
const FString& Url,
TFunction<void(const FPgosBuffer* data)> SaveCallback,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Url | const FString& | The url to download. |
| SaveCallback | TFunction<void(const FPgosBuffer* data)> | 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. |
| ResultCallback | TFunction<void(const FPgosResult& Ret)> | The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject. |
Return: int32
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 SavePath File path to write the data to. Pass in an ANSI-encoded path if the parameter type is not FString.
* @param ProgressCallback Data transfer progress callback, which will be called in an ASYNCHRONOUS CHILD THREAD.
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
* @return The id for the requested download task, zero if failed to create.
*/
int32 HttpDownloadFile(
const FString& Url,
const FString& SavePath,
TFunction<void(const FPgosHttpDownloadProgressInfo* data)> ProgressCallback,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Url | const FString& | The url to download. |
| SavePath | const FString& | File path to write the data to. Pass in an ANSI-encoded path if the parameter type is not FString. |
| ProgressCallback | TFunction<void(const FPgosHttpDownloadProgressInfo* data)> | Data transfer progress callback, which will be called in an ASYNCHRONOUS CHILD THREAD. |
| ResultCallback | TFunction<void(const FPgosResult& Ret)> | The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject. |
Return: int32
The id for the requested download task, zero if failed to create.
CancelHttpDownload
Cancel a requested download task.
/**
* Cancel a requested download task.
*
* @param TaskId The download task id.
*/
void CancelHttpDownload(
int32 TaskId) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| TaskId | int32 | The download task id. |
Return: void