Initialization and process - modio/modio-sdk-legacy GitHub Wiki
modio::Instance
Instance::Instance(u32 environment, u32 game_id, const std::string& api_key);
Instance::Instance(u32 environment, u32 game_id, bool retrieve_mods_from_other_games, const std::string& api_key, const std::string& root_path);
Initializes mod.io SDK on your project to access API functionality. This will setup a .modio/
directory as mod.io working directory in your project's path.
Name | Type | Description |
---|---|---|
environment | u32 |
Server Environment. |
game_id | u32 |
Your game unique identifier. |
retrieve_mods_from_other_games | bool |
If set to true, mods from other games will also be retrieved in the User's functions. |
api_key | const std::string& | Your game unique API key, grab this from the mod.io website. |
root_path | const std::string& | Optional parameter: You can change the root path where the .modio directory will reside. The ./modio directory contains the installed mods as well as all the files the mod.io handles behind the scene. The root path will be the working directory if not explicitly defined. |
Example:
modio::Instance modio_instance(MODIO_ENVIRONMENT_TEST, 7, "e91c01b8882f4affeddd56c96111977b");
process
void Instance::process();
This function handles transfers and callbacks in an non-blocking way. We recommend calling it regularly when performance is not critical, for example in menus or modding tools. Be mindful this function may impact the frame rate and online latency, we recommend not calling it in-game or better yet you could let your players decide. Additionally does the following work behinds the scenes:
- Download mods when the logged user subscribed. installDownloadedMods
- Uninstalls mods when the logged user unsubscribed.
- Redownload modfiles when a new version is available regardless if the user is logged in.
- Redownloads installed mods cache regardless if the user is logged in. Mod cache information is accessible through the getIntalledMods function.
This functionality is achieved by polling the API events endpoints. Polling occur every 15s by default so it should take about that amount of time to reflect the changes.
Example:
modio_instance.process();