Hi all,
Here's a small source file that adds a custom resource type enabling resource retrieval from a web server. I've tested it on windows/linux/osx but haven't tried iOS nor Android yet.
The main use for it is during debug as it allows one to run a game on a remote device (like a phone or a table for example) while having the resource on a local computer. As hotloading is supported, one can easily modify resource locally (sound, config, textures, ...) and see the effect directly on the device in real time.
It can even be used over internet for cooperative work, though it won't be as responsive due to latency.
Lastly, it can also be used in production to retrieve remote resources like announcements, custom xmas skins or whatever you want. =)
In your "game.cpp" where your init function lies:
#include "orxRemote.c"
And then simply call it first thing from your game's init function so that the support for web/remote resource will be enabled before any resource is actually loaded (beside the main config file that gets loaded right at the beginning):
orxSTATUS orxFASTCALL GameInit()
{
orxSTATUS eResult;
eResult = orxRemote_Init();
// Inits everything else below
}
In your main config file you can then add your server (you can actually have more than one) to the resource paths, so that they get searched first when a resource is requested. If not found, it'll then look into your dev folders for the original resources. If the host:port is omitted, localhost:8080 will be used.
Something like this:
[Resource]
Texture = texture # data/texture
In this example, go to your exe folder, and run one like this:
twistd -no web --path ./data
If you look at the web server log, you'll see all orx's requests going through: GET requests to retrieve actual content and HEAD requests to find if a file exist and to check for modification.
If you have any question/comments, just let me know! :)
Cheers,
Rom
PS: I might merge orxArchive.c with orxRemote.c in the future, for more convenience.