Skip to main content

Server 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.

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 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:

ParamTypeDescription
Urlconst FString&The url to download.
SaveCallbackTFunction<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.
ResultCallbackTFunction<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:

ParamTypeDescription
Urlconst FString&The url to download.
SavePathconst FString&File path to write the data to. Pass in an ANSI-encoded path if the parameter type is not FString.
ProgressCallbackTFunction<void(const FPgosHttpDownloadProgressInfo* data)>Data transfer progress callback, which will be called in an ASYNCHRONOUS CHILD THREAD.
ResultCallbackTFunction<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:

ParamTypeDescription
TaskIdint32The download task id.

Return: void