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

Subscriptions (C compatible)

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

modioSubscribeToMod

void modioSubscribeToMod(void* object, u32 mod_id, void (*callback)(void* object, ModioResponse response, ModioMod mod));

Wrapped by: Subscriptions#subscribetomod

API endpoint used: Subscribe to Mod

Subscribe the authenticated user to a corresponding mod.

Function parameters

Name Type Description
object void* Context parameter.
mod_id u32 Mod's unique identifier.
callback void (*callback)(void* object, ModioResponse response, ModioMod mod) Function called once the process finished.

Callback parameters

Name Type Description
object void* Context parameter.
response ModioResponse ModioResponse object that contains the mod.io response status.
mod ModioMod ModioMod object the user just subscribed to.

Example

void onSubscribeToMod(void* object, ModioResponse response, ModioMod mod)
{
  if(response.code == 201)
  {
    //Subscribed to mod successfully
  }
}

[...]

modioSubscribeToMod(NULL, mod_id, &onSubscribeToMod);

modioUnsubscribeFromMod

void modioUnsubscribeFromMod(void* object, u32 mod_id, void (*callback)(void* object, ModioResponse response));

Wrapped by: Subscriptions#unsubscribefrommod

API endpoint used: Unsubscribe from Mod

Unsubscribe the authenticated user from the corresponding mod.

Function parameters

Name Type Description
object void* Context parameter.
mod_id u32 Mod's unique identifier.
callback void (*callback)(void* object, ModioResponse response) Function called once the process finished.

Callback parameters

Name Type Description
object void* Context parameter.
response ModioResponse ModioResponse object that contains the mod.io response status.

Example

void onUsubscribeFromMod(void* object, ModioResponse response)
{
  if(response.code == 204)
  {
    //Unsubscribed from mod successfully
  }
}

[...]

modioUnsubscribeFromMod(NULL, mod_id, &onUsubscribeFromMod);

modioIsCurrentUserSubscribed

bool modioIsCurrentUserSubscribed(u32 mod_id);

Wrapped by: Subscriptions#iscurrentusersubscribed

API endpoint used: Get User Subscriptions

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 = modioIsCurrentUserSubscribed(mod_id);

modioGetCurrentUserSubscriptionsCount

u32 modioGetCurrentUserSubscriptionsCount();

Wrapped by: Subscriptions#getcurrentusersubscriptions

API endpoint used: Get User Subscriptions

Returns the amount of mods the current user has subscribed.

Example

u32 subscription_count = modioGetCurrentUserSubscriptionsCount();

modioGetCurrentUserSubscriptions

void modioGetCurrentUserSubscriptions(u32 *mod_id_array);

Wrapped by: Subscriptions#getcurrentusersubscriptions

API endpoint used: Get User Subscriptions

Returns an array containing the mod ids that the current user has subscribed.

Function parameters

Name Type Description
mod_id_array u32* Array where the contents of the list will be copied.

Example

u32 array_size = modioGetCurrentUserSubscriptionsCount();
u32 *user_subscriptions = malloc(array_size * sizeof(u32));
modioGetCurrentUserSubscriptions(user_subscriptions);

[...]

free(user_subscriptions);

Contents

Clone this wiki locally