ToxMod Server SDK 1.5.2
ToxMod Server-Side SDK
 
Loading...
Searching...
No Matches
tox_server.h File Reference
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  tox_server_instance_t
 
struct  tox_server_config_t
 

Macros

#define TOX_SERVER_DEF_PREFIX
 
#define TOX_SERVER_VERSION   "1.5.2"
 

Typedefs

typedef void *(* tox_server_malloc_callback) (size_t size)
 
typedef void(* tox_server_free_callback) (void *ptr)
 
typedef void *(* tox_server_realloc_callback) (void *ptr, size_t size)
 
typedef char *(* tox_server_strdup_callback) (const char *str)
 
typedef void *(* tox_server_calloc_callback) (size_t nmemb, size_t size)
 

Enumerations

enum  TOX_SERVER_ERROR {
  TOX_SERVER_NO_ERROR = 0 , TOX_SERVER_UNKNOWN_ERROR , TOX_SERVER_BAD_INSTANCE , TOX_SERVER_BAD_ACCOUNT_UUID ,
  TOX_SERVER_BAD_API_KEY , TOX_SERVER_BAD_CONFIG , TOX_SERVER_BAD_PLAYER_NAME , TOX_SERVER_BAD_SESSION_NAME ,
  TOX_SERVER_BAD_MAX_NUM_PACKETS , TOX_SERVER_BAD_MAX_PACKET_SIZE , TOX_SERVER_BAD_PACKET , TOX_SERVER_CURL_ERROR ,
  TOX_SERVER_EMPTY_PACKET , TOX_SERVER_PACKET_TOO_LARGE , TOX_SERVER_CIRCULAR_BUFFER_FULL , TOX_SERVER_UPLOAD_QUEUE_FULL ,
  TOX_SERVER_BAD_MEM_FUNCTION , TOX_SERVER_UPLOAD_METADATA_FAILED , TOX_SERVER_BAD_PLAYER_ALIAS , TOX_SERVER_BAD_SESSION_ALIAS ,
  TOX_SERVER_BAD_PLAYER_LIST , TOX_SERVER_PROXIMITY_CHAT_DISABLED , TOX_SERVER_BAD_REALTIME_CONFIG
}
 

Functions

const char * tox_server_get_version (void)
 
TOX_SERVER_ERROR tox_server_set_log_info_callback (void(*log_info_callback)(const char *))
 
TOX_SERVER_ERROR tox_server_set_log_error_callback (void(*log_error_callback)(const char *))
 
const char * tox_server_error_name (TOX_SERVER_ERROR error)
 
TOX_SERVER_ERROR tox_server_global_init (const char *account_uuid, const char *api_key, const char *single_tenant_prefix)
 
TOX_SERVER_ERROR tox_server_global_init_mem (const char *account_uuid, const char *api_key, const char *single_tenant_prefix, tox_server_malloc_callback tox_malloc, tox_server_free_callback tox_free, tox_server_realloc_callback tox_realloc, tox_server_strdup_callback tox_strdup, tox_server_calloc_callback tox_calloc)
 
TOX_SERVER_ERROR tox_server_global_cleanup (void)
 
TOX_SERVER_ERROR tox_server_create_instance (tox_server_instance_t *tox_instance_ptr, const tox_server_config_t *tox_server_config_ptr)
 
TOX_SERVER_ERROR tox_server_destroy_instance (tox_server_instance_t *tox_instance_ptr)
 
TOX_SERVER_ERROR tox_server_get_internal_player_uuid (tox_server_instance_t *tox_instance_ptr, const char **internal_player_uuid)
 
TOX_SERVER_ERROR tox_server_get_internal_session_uuid (tox_server_instance_t *tox_instance_ptr, const char **internal_session_uuid)
 
TOX_SERVER_ERROR tox_server_add_session_data (tox_server_instance_t *tox_instance_ptr, const char *session_data)
 
TOX_SERVER_ERROR tox_server_set_proximity_chat_player_can_hear (tox_server_instance_t *tox_instance_ptr, const char *const *players, unsigned int num_players)
 
TOX_SERVER_ERROR tox_server_set_proximity_chat_can_hear_player (tox_server_instance_t *tox_instance_ptr, const char *const *players, unsigned int num_players)
 
TOX_SERVER_ERROR tox_server_add_packet (tox_server_instance_t *tox_instance_ptr, const unsigned char *packet, unsigned int packet_size)
 
TOX_SERVER_ERROR tox_server_add_packets_nonrealtime (tox_server_instance_t *tox_instance_ptr, const unsigned char **packets, const unsigned int *packet_sizes, unsigned int num_packets)
 
TOX_SERVER_ERROR tox_server_set_global_muted (tox_server_instance_t *tox_instance_ptr, int muted)
 
TOX_SERVER_ERROR tox_server_set_player_muted (tox_server_instance_t *tox_instance_ptr, const char *player, int muted)
 
TOX_SERVER_ERROR tox_server_set_players_muted_at_join (tox_server_instance_t *tox_instance_ptr, const char *const *players, unsigned int num_players)
 
TOX_SERVER_ERROR tox_server_run_buffer_copy (tox_server_instance_t *tox_instance_ptr)
 
TOX_SERVER_ERROR tox_server_begin_upload (tox_server_instance_t *tox_instance_ptr)
 
TOX_SERVER_ERROR tox_server_run_all_uploads_with_timeout (int *num_running_uploads, int wait_timeout_milliseconds)
 
TOX_SERVER_ERROR tox_server_run_all_uploads (int *num_running_uploads)
 
TOX_SERVER_ERROR tox_server_set_player_alias (tox_server_instance_t *tox_instance_ptr, const char *player_alias)
 
TOX_SERVER_ERROR tox_server_set_session_alias (tox_server_instance_t *tox_instance_ptr, const char *session_alias)
 

Detailed Description

Macro Definition Documentation

◆ TOX_SERVER_DEF_PREFIX

#define TOX_SERVER_DEF_PREFIX

Definition prefix used to export functions

◆ TOX_SERVER_VERSION

#define TOX_SERVER_VERSION   "1.5.2"

The version of the ToxMod server library - this updates anytime Modulate ships a new libtox with bugfixes, performance improvements, API changes, etc. ToxMod follows semantic versioning, therefore: Major (first number) versions are not compatible Minor (second number) versions are backwards compatible - applications compiled against less recent versions can link with more recent versions, but not necessarily vice versa Patch (third number) all versions compatible - internal differences only Dev Build - "d" for dev build, nothing for external release

Typedef Documentation

◆ tox_server_malloc_callback

typedef void *(* tox_server_malloc_callback) (size_t size)

Typedefs to memory callback functions are provided to simplify the API - not needed unless you're using custom memory allocation

Enumeration Type Documentation

◆ TOX_SERVER_ERROR

Error value responses from ToxMod server functions; use tox_server_error_name() to get related message on error.

Enumerator
TOX_SERVER_NO_ERROR 

Default return value for successful function calls.

TOX_SERVER_UNKNOWN_ERROR 

Returned in case of internal library errors, and should not be encountered during normal use of the SDK.

TOX_SERVER_BAD_INSTANCE 

returned if the tox_server_instance_t parameter was not initialized by tox_server_create_instance(), or has otherwise become corrupted.

TOX_SERVER_BAD_ACCOUNT_UUID 

Returned if an account UUID is null

TOX_SERVER_BAD_API_KEY 

Returned if an operation was performed using a null API key

TOX_SERVER_BAD_CONFIG 

Returned if a null tox_server_config_t is used

TOX_SERVER_BAD_PLAYER_NAME 

Returned if a null player name is passed

TOX_SERVER_BAD_SESSION_NAME 

Returned if a null session name is passed

TOX_SERVER_BAD_MAX_NUM_PACKETS 

Returned if the circular buffer max num packets is 0

TOX_SERVER_BAD_MAX_PACKET_SIZE 

Returned if the max packet size is 0

TOX_SERVER_BAD_PACKET 

Returned if something is wrong with the packet array, either one of the packets is null or the array is null

TOX_SERVER_CURL_ERROR 

Returned if curl fails to initialize a valid multi handle

TOX_SERVER_EMPTY_PACKET 

Returned if the packet is a null pointer or packet_size is 0

TOX_SERVER_PACKET_TOO_LARGE 

Returned if the packet size is greater than tox_server_config_t.max_packet_size, tox_server_config_t.max_packet_size may need to be increased

TOX_SERVER_CIRCULAR_BUFFER_FULL 

Returned if the underlying circular buffer has been saturated by adding packets - either increase the tox_server_config_t.circular_buffer_max_num_packets to hold more packets and avoid dropping them, or increase the rate at which tox_server_run_buffer_copy() is run to drain the circular buffer more often

TOX_SERVER_UPLOAD_QUEUE_FULL 

Returned if the underlying clip upload buffer is full, so a new Ogg data buffer could not be added to the upload queue and has been dropped. This indicates that tox_server_begin_upload() has run insufficiently often on this tox_server_instance_t to empty the upload queue into curl for active uploading

TOX_SERVER_BAD_MEM_FUNCTION 

Returned if if NULL is passed instead of one of the required memory functions (malloc, free, realloc)

TOX_SERVER_UPLOAD_METADATA_FAILED 

Returned if the player or session alias failed to upload (only applicable if tox_server_config_t.obscure_names is 0).

TOX_SERVER_BAD_PLAYER_ALIAS 

Returned if player alias is a null pointer

TOX_SERVER_BAD_SESSION_ALIAS 

Returned if session alias is a null pointer

TOX_SERVER_BAD_PLAYER_LIST 

Returned if the player list is null but num_players isn't 0.

TOX_SERVER_PROXIMITY_CHAT_DISABLED 

Returned if proximity_chat_session is 0 in the instance's config.

TOX_SERVER_BAD_REALTIME_CONFIG 

Returned if the tox_server_instance passed in has been set up for realtime use and an attempt is made to use non-realtime functionality

Function Documentation

◆ tox_server_get_version()

const char * tox_server_get_version ( void )

Return the version string for the library that this is built with
Should match TOX_SERVER_VERSION

Returns
Version number of the ToxMod Server SDK

◆ tox_server_set_log_info_callback()

TOX_SERVER_ERROR tox_server_set_log_info_callback ( void(* log_info_callback )(const char *))

Set a user-defined callback to print/log info messages from ToxMod
If this is not called, ToxMod will print info messages to stdout. Passing a null pointer will restore the default logging behavior using stdout/stderr.

Parameters
[in]log_info_callback- logging callback
Returns
Examples
multistream_example.cpp.

◆ tox_server_set_log_error_callback()

TOX_SERVER_ERROR tox_server_set_log_error_callback ( void(* log_error_callback )(const char *))

Set a user-defined callback to print/log error messages from ToxMod
If this is not called, ToxMod will print error messages to stderr. Passing a null pointer will restore the default logging behavior using stdout/stderr.

Parameters
[in]log_error_callback- logging callback
Returns
Examples
multistream_example.cpp.

◆ tox_server_error_name()

const char * tox_server_error_name ( TOX_SERVER_ERROR error)

Return the associated string for a ToxMod Server error - useful in log messages

Parameters
[in]error- the tox error for which to retrieve an error string
Returns
Error message as a string
Examples
multistream_example.cpp.

◆ tox_server_global_init()

TOX_SERVER_ERROR tox_server_global_init ( const char * account_uuid,
const char * api_key,
const char * single_tenant_prefix )

Global initialization, setting state for curl and account parameters for all tox_server_instance_t objects. This must be called before any other tox_server functions aside from tox_server_get_version() and tox_server_error_name().
An error from this function means that ToxMod will not work properly and should be aborted.

Parameters
[in]account_uuidProvided by Modulate directly or retrieved from the Admin page in the web console.
[in]api_keyProvided by Modulate directly or retrieved from the Admin page in the web console
[in]single_tenant_prefixProvided by Modulate directly for single tenancy customers. If not applicable, pass in a null pointer.
Returns
Examples
basic_example.c.

◆ tox_server_global_init_mem()

TOX_SERVER_ERROR tox_server_global_init_mem ( const char * account_uuid,
const char * api_key,
const char * single_tenant_prefix,
tox_server_malloc_callback tox_malloc,
tox_server_free_callback tox_free,
tox_server_realloc_callback tox_realloc,
tox_server_strdup_callback tox_strdup,
tox_server_calloc_callback tox_calloc )

Global initialization using custom memory allocators, which replaces all memory management performed by ToxMod with allocations/frees using the specified callbacks. Additionally, memory allocated by the curl dependency as used by ToxMod will use these callbacks, though depending on which dependencies to curl are installed (such as the SSL library), they themselves may not use these callbacks. The standard Ogg library dependency does not use these callbacks by default. This function replaces tox_global_init(), see that documentation above for more information.

Parameters
[in]account_uuidProvided by Modulate directly or retrieved from the Admin page in the web console.
[in]api_keyProvided by Modulate directly or retrieved from the Admin page in the web console
[in]single_tenant_prefixProvided by Modulate directly for single tenancy customers. If not applicable, pass in a null pointer.
[in]tox_malloca callback for ToxMod to get a pointer to allocated memory.
[in]tox_freea callback to free memory allocated with tox_malloc, which must use the same heap as the tox_malloc callback.
[in]tox_realloca callback implementing realloc, for ToxMod to use, which must use the same head as the tox_malloc and tox_free callbacks.
[in]tox_strdupan optional pointer to a strdup implementation, or if null, ToxMod will use a default implementation based on the specified tox_malloc and tox_free functions.
[in]tox_callocan optional pointer to a calloc implementation, or if null, ToxMod will use a default implementaiton based on the specified tox_malloc function.
Returns
returns a TOX_SERVER_ERROR
Examples
multistream_example.cpp.

◆ tox_server_global_cleanup()

TOX_SERVER_ERROR tox_server_global_cleanup ( void )

Global cleanup of the initialization from tox_server_global_init(). Call only once no more tox_server functions (excluding tox_server_get_version() and tox_server_error_name()) will be called.

Examples
basic_example.c, and multistream_example.cpp.

◆ tox_server_create_instance()

TOX_SERVER_ERROR tox_server_create_instance ( tox_server_instance_t * tox_instance_ptr,
const tox_server_config_t * tox_server_config_ptr )

Create a tox_server_instance_t to store internal state specific to a single player in voice chat session. One should be created for each player in a voice chat session, for each voice chat session. Internal storage is allocated to preserve the config values passed in, so the tox_server_config_t object may be discarded after this function returns.

Parameters
[in]tox_instance_ptrPointer to a fresh tox_server_instance_t
[in]tox_server_config_ptrPointer to a tox_server_config_t
Returns

Example:

tox_server_instance_t tox_instance;
tox_server_config_t tox_config = {
.player_name_unique = "player1",
.session_name_unique = "chatroom1",
.circular_buffer_max_num_packets = 50,
.max_packet_size = 1275,
.obscure_names = 0
};
TOX_SERVER_ERROR tox_error = tox_server_create_instance(&tox_instance, &tox_config);
Definition tox_server.h:147
Definition tox_server.h:136
TOX_SERVER_ERROR tox_server_create_instance(tox_server_instance_t *tox_instance_ptr, const tox_server_config_t *tox_server_config_ptr)
TOX_SERVER_ERROR
Definition tox_server.h:55
Examples
basic_example.c, and multistream_example.cpp.

◆ tox_server_destroy_instance()

TOX_SERVER_ERROR tox_server_destroy_instance ( tox_server_instance_t * tox_instance_ptr)

Destroy a tox_server_instance_t to free internal state. This must be done when tox_server functions will no longer be called on this tox_server_instance_t, and is not threadsafe with other tox_server functions when operating on the same tox_server_instance_t.

Parameters
[in]tox_instance_ptrPointer to the tox_server_jnstance_t to be destroyed
Returns
Examples
basic_example.c, and multistream_example.cpp.

◆ tox_server_get_internal_player_uuid()

TOX_SERVER_ERROR tox_server_get_internal_player_uuid ( tox_server_instance_t * tox_instance_ptr,
const char ** internal_player_uuid )

Get the ToxMod-internal anonymous UUID associated with the provided player. Retrieving this and storing it in your own database allows you to consume messages from ToxMod (e.g. "a moderator banned <player_uuid>") and relate them back to your internal player database or players' usernames, without ToxMod storing any player usernames. If it is acceptable for ToxMod to store player usernames, you can avoid storing this relationship yourself. Do this by providing ToxMod a player alias which you can consume later - such as the player username or internal database ID - using tox_set_player_alias, in which case the above messages will also include the alias (e.g. "a moderator banned <player_uuid>, alias: <player_alias>").

Parameters
[in]tox_instance_ptrPointer to the tox_server_instance_t of the player in question
[out]internal_player_uuidThe toxmod internal UUID used to identify the player in question. This will remain valid until the corresponding tox_server_instance_t is destroyed.
Returns

Example:

const char* player_uuid;
tox_error = tox_server_get_internal_player_uuid(&tox_instance, &player_uuid);
if(!tox_error)
// save player_uuid to some database, associated with the player's username
TOX_SERVER_ERROR tox_server_get_internal_player_uuid(tox_server_instance_t *tox_instance_ptr, const char **internal_player_uuid)
Examples
multistream_example.cpp.

◆ tox_server_get_internal_session_uuid()

TOX_SERVER_ERROR tox_server_get_internal_session_uuid ( tox_server_instance_t * tox_instance_ptr,
const char ** internal_session_uuid )

Get the ToxMod-internal anonymous UUID associated with the provided session. This works much like tox_get_internal_player_uuid(), except that it is associated with a session instead of a player. Retrieving and storing the session UUID in your own database allows you to associate the UUID included in moderation messages with your internal session database or sessions' names, without ToxMod storing any session names. Alternatively, you can avoid storing this relationship yourself by providing ToxMod a session alias (i.e. the session name itsef) which will be passed back to you in moderation messages.

Parameters
[in]tox_instance_ptrPointer to the tox_server_instance_t of the session in question
[out]internal_session_uuidThe toxmod internal UUID used to identify the session in question. This will remain valid until the corresponding tox_server_instance_t is destroyed.
Returns

Example:

const char* session_uuid;
tox_error = tox_server_get_internal_session_uuid(&tox_instance, &session_uuid);
if(!tox_error)
// save session_uuid to some database, associated with the session's name
TOX_SERVER_ERROR tox_server_get_internal_session_uuid(tox_server_instance_t *tox_instance_ptr, const char **internal_session_uuid)
Examples
multistream_example.cpp.

◆ tox_server_add_session_data()

TOX_SERVER_ERROR tox_server_add_session_data ( tox_server_instance_t * tox_instance_ptr,
const char * session_data )

Send additional session context/data/events to ToxMod for use in assisting moderation. Since each game has different structure and different relevant events that may contribute to player toxicity, the format for this session data is determined on a per-customer basis. Please reach out to your Modulate account representative for more information.

Parameters
[in]tox_instance_ptrPointer representing the player/session in question
[in]session_dataThe session data to pass to ToxMod. This is copied to internal storage and does not need to be preserved after this function returns.
Returns

Example:

const char* event = "{\"Event\": \"killed_by\", \"Other Participants\": [\"player2\"]}";
tox_error = tox_server_add_session_data(&tox_instance, event);
TOX_SERVER_ERROR tox_server_add_session_data(tox_server_instance_t *tox_instance_ptr, const char *session_data)

◆ tox_server_set_proximity_chat_player_can_hear()

TOX_SERVER_ERROR tox_server_set_proximity_chat_player_can_hear ( tox_server_instance_t * tox_instance_ptr,
const char *const * players,
unsigned int num_players )

Set a list of players that this player can hear. This should be the full list of players that this player can hear at the time of the function call, and should be called each time that that list changes. For example, if another player leaves proximity chat range and this player can no longer hear them, call this function with the remaining list of players that this player can hear. Use either this function or tox_server_set_proximity_chat_can_hear_player() to specify proximity chat information, not both.

Parameters
[in]tox_instance_ptrPointer referencing the primary player in question
[in]playersArray of players who the primary player can hear. This specifies the ToxMod-internal UUIDs associated with those players, NOT the raw string player names used at ToxMod instance creation. This is an optimization to prevent the SDK from re-hashing the names to UUIDs on each function call. These internal UUIDs can be retrieved from the tox_server_instance objects corresponding to the other players by calling tox_server_get_internal_player_uuid() on the instance object.
[in]num_playersLength of the players array
Returns

Example:

const char* players[] = {"0ce128a7-cef2-4d04-bb1e-e585c2276547",
"6e752edd-0264-4bf2-afb0-22213389e243"};
tox_error = tox_server_set_proximity_chat_player_can_hear(&tox_instance, players, 2);
TOX_SERVER_ERROR tox_server_set_proximity_chat_player_can_hear(tox_server_instance_t *tox_instance_ptr, const char *const *players, unsigned int num_players)
Examples
multistream_example.cpp.

◆ tox_server_set_proximity_chat_can_hear_player()

TOX_SERVER_ERROR tox_server_set_proximity_chat_can_hear_player ( tox_server_instance_t * tox_instance_ptr,
const char *const * players,
unsigned int num_players )

Set a list of players that can hear this player. This should be the full list of players that can hear this player at the time of the function call, and should be called each time that that list changes. For example, if another player leaves proximity chat range and they can no longer hear this player, call this function with the remaining list of players that can hear this player. Use either this function or tox_server_set_proximity_chat_player_can_hear() to specify proximity chat information, not both.

Parameters
[in]tox_instance_ptrPointer referencing the primary player in question
[in]playersArray of players who can hear the primary player. This specifies the ToxMod-internal UUIDs associated with those players, NOT the raw string player names used at ToxMod instance creation. This is an optimization to prevent the SDK from re-hashing the names to UUIDs on each function call. These internal UUIDs can be retrieved from the tox_server_instance objects corresponding to the other players by calling tox_server_get_internal_player_uuid() on the instance object.
[in]num_playersLength of the players array
Returns

Example:

const char* players[] = {"0ce128a7-cef2-4d04-bb1e-e585c2276547",
"6e752edd-0264-4bf2-afb0-22213389e243"};
tox_error = tox_server_set_proximity_chat_can_hear_player(&tox_instance, players, 2);
TOX_SERVER_ERROR tox_server_set_proximity_chat_can_hear_player(tox_server_instance_t *tox_instance_ptr, const char *const *players, unsigned int num_players)

◆ tox_server_add_packet()

TOX_SERVER_ERROR tox_server_add_packet ( tox_server_instance_t * tox_instance_ptr,
const unsigned char * packet,
unsigned int packet_size )

Add a new Opus packet from the associated player in the associated voice chat room to the tox_server_instance_t for processing. This function is realtime safe, and is implemented as a lightweight copy to a circular buffer using atomics. Errors indicate that the packet was not added to the circular buffer but do not otherwise compromise the tox_server_instance_t state.

Parameters
[in]tox_instance_ptrPointer referencing the player/session to add the packet to
[in]packetEncoded Opus data packet
[in]packet_sizeSize in bytes of the encoded Opus data packet
Returns
Examples
basic_example.c, and multistream_example.cpp.

◆ tox_server_add_packets_nonrealtime()

TOX_SERVER_ERROR tox_server_add_packets_nonrealtime ( tox_server_instance_t * tox_instance_ptr,
const unsigned char ** packets,
const unsigned int * packet_sizes,
unsigned int num_packets )

Add an array of non-realtime Opus packets from the associated player in the associated voice chat room to the tox_server_instance_t for processing. This function is not realtime safe and can block when called. This function is thread safe, and is designed to be called from multiple threads concurrently.

Note
Upload timestamps for audio passed in through this function will be set based on the relative position of each audio clip within the larger segment passed in. For example, if 45 seconds of audio is passed in it will be divided into 3 ToxMod clips. The first clip will have an upload timestamp offset as if it were 30 seconds delayed. The second clip will be offset to 15 seconds delayed, and the third clip will have no offset.
Parameters
[in]tox_instance_ptrPointer referencing the player/session to add the packet to
[in]packetsArray of encoded Opus data packets
[in]packet_sizesArray with sizes in bytes of the encoded Opus data packets
[in]num_packetsNumber of Opus packets
Returns

◆ tox_server_set_global_muted()

TOX_SERVER_ERROR tox_server_set_global_muted ( tox_server_instance_t * tox_instance_ptr,
int muted )

Signal to ToxMod that the player associated with an instance has muted or unmuted voice chat entirely.

Parameters
[in]tox_instance_ptrreference to the tox_instance_t for the player in question
[in]muted0 signals that voice chat was unmuted, 1 signals that voice chat was muted.
Returns

◆ tox_server_set_player_muted()

TOX_SERVER_ERROR tox_server_set_player_muted ( tox_server_instance_t * tox_instance_ptr,
const char * player,
int muted )

Signal to ToxMod that the player associated with an instance has muted or unmuted another player.

The player argument specifies the ToxMod-internal UUID associated with the muted/unmuted player, NOT the raw string player name used at ToxMod instance creation. This is an optimization to prevent the SDK from re-hashing the name to a UUID on each function call. The internal UUID can be retrieved from the tox_server_instance_t objects corresponding to the muted/unmuted player by calling tox_server_get_internal_player_uuid() on the instance object.

Parameters
[in]tox_instance_ptrreference to the tox_instance_t for the primary player in question
[in]playerthe ToxMod-internal UUID of the player being muted/unmuted
[in]muted0 signals that the player was unmuted, 1 signals that the player was muted.
Returns
Examples
multistream_example.cpp.

◆ tox_server_set_players_muted_at_join()

TOX_SERVER_ERROR tox_server_set_players_muted_at_join ( tox_server_instance_t * tox_instance_ptr,
const char *const * players,
unsigned int num_players )

Notify ToxMod that the player associated with an instance has a preexisting persistent mute set on one or more players in this session. ToxMod will treat this differently than a call to tox_server_set_player_muted(), which should be used for real-time muting actions.

This is intended to be called when the associated player joins a session, and again if a player who the associated player has muted joins the session later.

Note
The players array of strings specifies the ToxMod-internal UUIDs associated with those players, NOT the raw string player names used at ToxMod instance creation. This is an optimization to prevent the SDK from re-hashing the names to UUIDs on each function call. These internal UUIDs can be retrieved from the tox_server_instance_t objects corresponding to the other players by calling tox_server_get_internal_player_uuid() on the instance object.
Parameters
[in]tox_instance_ptrreference to the tox_instance_t for the primary player in question
[in]playersan array of the ToxMod-internal UUIDs of the players who are muted-at-join
[in]num_playerslength of the players list
Returns

◆ tox_server_run_buffer_copy()

TOX_SERVER_ERROR tox_server_run_buffer_copy ( tox_server_instance_t * tox_instance_ptr)

Run on a timed loop to drain the circular buffer of the tox_server_instance_t of new packets and into an encoded Ogg data buffer. When the underlying Ogg data buffer is ready to upload, this function will add that file buffer to an upload queue and allocate a new data buffer. This function should not be run in a realtime audio loop.

Parameters
[in]tox_instance_ptrreference to the tox_instance_t for the player/session pair in question
Returns
  • TOX_SERVER_NO_ERROR - function executed successfully
  • TOX_SERVER_UPLOAD_QUEUE_FULL - the underlying clip upload buffer is full, so a new Ogg data buffer could not be added to the upload queue and has been dropped. This indicates that tox_server_begin_upload has run insufficiently often on this tox_server_instance_t to empty the upload queue into curl for active uploading
Examples
basic_example.c, and multistream_example.cpp.

◆ tox_server_begin_upload()

TOX_SERVER_ERROR tox_server_begin_upload ( tox_server_instance_t * tox_instance_ptr)

Run on a timed loop to empty the upload queue and begin uploading the relevant clips. This should be run once every few seconds to ensure low latency between an offense occurring and it being escalated by ToxMod, and to ensure that the upload queue does not saturate.

Parameters
[in]tox_instance_ptrreference to the tox_instance_t for the player/session pair in question
Returns
Examples
basic_example.c, and multistream_example.cpp.

◆ tox_server_run_all_uploads_with_timeout()

TOX_SERVER_ERROR tox_server_run_all_uploads_with_timeout ( int * num_running_uploads,
int wait_timeout_milliseconds )

Run on a loop to progress all in-progress uploads across all tox_server_instance_t objects. This function should be run with no caller-side waiting function, as the function will internally wait up to wait_timeout_milliseconds if no uploading work is available to do.

Note
100 is a good default for wait_timeout_milliseconds, such that this function will run ~10x/second if there is no uploading work to do.
Parameters
[out]num_running_uploadsReference to an int to store the number of uploads still running
[in]wait_timeout_millisecondsMaximum time period to wait for work to do in milliseconds
Returns
Examples
basic_example.c, and multistream_example.cpp.

◆ tox_server_run_all_uploads()

TOX_SERVER_ERROR tox_server_run_all_uploads ( int * num_running_uploads)

Run on a timed loop to progress all in-progress uploads across all tox_server_instance_t objects. This should be run once every few seconds to ensure that uploads complete in a timely manner. Note: this function may need to be run more often if many uploads are running, up to ~20x/second if multiple hundreds of uploads are occurring.

Parameters
[out]num_running_uploadsReference to an int to store the number of uploads still running
Returns

◆ tox_server_set_player_alias()

TOX_SERVER_ERROR tox_server_set_player_alias ( tox_server_instance_t * tox_instance_ptr,
const char * player_alias )

Save an alias for the associated player within ToxMod's database, to be passed back to you upon moderation actions. This avoids you having to store the ToxMod anonymous id and do the association yourself, as moderation actions will produce messages that you consume with the information "a moderator banned <player_uuid>, alias: <player_alias>" The player alias is copied to internal storage, and does not need to be preserved after this function returns.

Note
make sure to run tox_server_run_all_uploads_with_timeout() after calling this in order to perform the web request and upload the player alias to the ToxMod servers.
Parameters
[in]tox_instance_ptrreference to the tox_instance_t for the player/session pair in question
[in]player_aliasalias for the player in question
Returns

Example:

tox_error = tox_server_set_player_alias(&tox_instance, "player1");
TOX_SERVER_ERROR tox_server_set_player_alias(tox_server_instance_t *tox_instance_ptr, const char *player_alias)

◆ tox_server_set_session_alias()

TOX_SERVER_ERROR tox_server_set_session_alias ( tox_server_instance_t * tox_instance_ptr,
const char * session_alias )

Save an alias for the associated session within ToxMod's database, to be passed back to you upon moderation actions. This allows you to associate a session name with the conversations shown in the web console rather than the internal UUID ToxMod uses to identify sessions.

Parameters
[in]tox_instance_ptrreference to the tox_server_instance_t for the player/session pair in question
[in]session_aliasalias for the session in question

Additional error codes

Example:

tox_error = tox_server_set_session_alias(&tox_instance, "session1");
TOX_SERVER_ERROR tox_server_set_session_alias(tox_server_instance_t *tox_instance_ptr, const char *session_alias)