The new class TCastleDownload allows to download data over http
and https
asynchronously, without blocking the main thread of the application. This means that you can trivially continue rendering and game logic, while some resource are being downloaded over the network.
I made a demo in examples/network/asynchronous_download/. It demonstrates multiple simultaneous downloads, and underneath a glTF animation is playing with smooth 60 FPS without any breaks.
The class supports all CGE URLs, like file
, http
, https
, castle-data
and more.
Manual chapter about networking was updated to reflect all new possibilities.
Features:
- The download can be observed (looking at Status, DownloadedBytes, TotalBytes).
-
When it’s finished, look at Contents (if success) or ErrorMessage (if error, that is
Status = dsError
). -
We can read MIME type from server (can be used throughout our engine to designate file type).
-
It’s actually a full-featured HTTP(S) web request. You can specify HttpMethod, like GET, POST, PUT etc. For POST, you can provide form data as PostData. Arbitrary HTTP headers can be specified using AddHeader.
More examples:
- examples/network/castle_download/ was reimplemented. It implements a simple command-line downloading tool (like
wget
orcurl
using our engine) usingTCastleDownload
. -
examples/network/remote_logging/ sends now asynchronous HTTP POST message using new
TCastleDownload
.
This feature was done thanks to your support on Patreon. It was requested by Peardox. Many thanks! If you like what I’m doing, please support our engine.
Start the discussion at Castle Game Engine Forum