Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Subscriptions

Ahmed Castro edited this page Oct 21, 2019 · 10 revisions

subscribeToMod

void Instance::subscribeToMod(u32 mod_id, const std::function<void(const modio::Response& response, const modio::Mod& mod)>& callback);

API endpoint used: Subscribe to Mod

Subscribe the authenticated user to a corresponding mod. This will automatically download the mod locally.

Function parameters

Name Type Description
mod_id u32 Mod's unique identifier.
callback const std::function<void(const modio::Response& response, const modio::Mod& mod)>& Function called once the process finished.

Callback parameters

Name Type Description
response const modio::Response& modio::Response object that contains the mod.io response status.
mod const modio::Mod& modio::Mod object the user just subscribed to.

Example

modio_instance.subscribeToMod(mod_id, [&](const modio::Response& response, const modio::Mod& mod)
{
  if(response.code == 201)
  {
    //Subscribed to mod successfully
  }
});

unsubscribeFromMod

void Instance::unsubscribeFromMod(u32 mod_id, const std::function<void(const modio::Response& response)>& callback);

API endpoint used: Unsubscribe from Mod

Unsubscribe the authenticated user from the corresponding mod. This will automatically uninstall the mod locally.

Function parameters

Name Type Description
mod_id u32 Mod's unique identifier.
callback const std::function<void(const modio::Response& response)>& Function called once the process finished.

Callback parameters

Name Type Description
response const modio::Response& modio::Response object that contains the mod.io response status.

Example

modio_instance.unsubscribeFromMod(mod_id, [&](const modio::Response& response)
{
  if(response.code == 204)
  {
    //Unsubscribed from mod successfully
  }
});

isCurrentUserSubscribed

bool Instance::isCurrentUserSubscribed(u32 mod_id)

Returns true if the authenticated user is subscribed to the corresponding mod.

Function parameters

Name Type Description
mod_id u32 Id of the corresponding mod

Example

bool is_subscribed = isCurrentUserSubscribed(mod_id);

getCurrentUserSubscriptions

const std::vector<u32> getCurrentUserSubscriptions();

Returns a std::vector of the mod ids that the current user has subscribed.

Example

std::vector<modio::InstalledMod> installed_mods = mod_instance.getCurrentUserSubscriptions();

Contents

Clone this wiki locally