Interface IPatchServerService
Contract for version lookups and patch binary downloads. All methods use a single API host URL (NGINX routes by path to the correct backend).
public interface IPatchServerService
Methods
DownloadPatch(string, string, string, long, Action<bool>, Action<string>, Action<DownloadStats>)
Asynchronously downloads a patch file from the server. When
expectedSha256 is provided, the downloaded file is hashed
after download and the operation fails (with onError) if
the digest does not match.
IEnumerator DownloadPatch(string patchUrl, string destinationFilePath, string expectedSha256, long expectedTotalBytes, Action<bool> onComplete, Action<string> onError, Action<DownloadStats> onProgress)
Parameters
patchUrlstringThe full URL of the patch file to download.
destinationFilePathstringFull path (including file name) the patch archive is written to. Parent directories are created if missing.
expectedSha256stringLowercase hex SHA-256 the downloaded file must match, or null/empty to skip verification.
expectedTotalByteslongTotal size the download is expected to be, from the version manifest's Size, or 0 when the server did not report one.
onCompleteAction<bool>Callback invoked upon successful download (and verification, if requested). The argument is
truewhen a patch archive was written todestinationFilePath, andfalsewhen the server reported the client is already up to date and there is nothing to apply.onErrorAction<string>Callback invoked with an error message upon failure.
onProgressAction<DownloadStats>Callback invoked periodically with a DownloadStats snapshot.
Returns
- IEnumerator
An IEnumerator for use in a Unity Coroutine.
Remarks
The expected size is passed in rather than read from the response so the caller can display a total before the first byte arrives, and so a truncated or chunked response cannot change what the player was told the download would be.
GetLatestVersion(string, string, Action<VersionConfig, PatchInfo>, Action<string>)
Asynchronously retrieves the latest client version from the API gateway.
When clientVersion is non-empty, the server may also return
patch metadata (SHA-256, size, availability) for that specific client version.
IEnumerator GetLatestVersion(string apiHost, string clientVersion, Action<VersionConfig, PatchInfo> onComplete, Action<string> onError)
Parameters
apiHoststringThe unified API host URL.
clientVersionstringThe client's current version string, or null/empty to request only the latest version.
onCompleteAction<VersionConfig, PatchInfo>Callback invoked with the latest VersionConfig and per-version PatchInfo upon success.
onErrorAction<string>Callback invoked with an error message upon failure.
Returns
- IEnumerator
An IEnumerator for use in a Unity Coroutine.